GithubHelp home page GithubHelp logo

fewpjs-oo-predicting-constructor-effects-instrumental's Introduction

Predicting Constructor Effects

Questions

class Rectangle {
  constructor(sideA, sideB) {
    this.sideA = sideA;
    this.sideB = sideB;
    this.area = sideA * sideB;
    this.perimeter = sideA * 2 + sideB * 2;
  }
}
  1. Given the example class above, what will all four properties be if let rectangle = new Rectangle(2,4) is run?

  2. What if let rectangle = new Rectangle(10,-4) is run?

class Book {
  constructor(title, author) {
    this.title = this.titleize(title);
    this.author = this.titleize(author);
  }

  titleize(string) {
    let words = string.split(' ');
    for (let n = 0; n < words.length; n++) {
      words[n] = words[n].charAt(0).toUpperCase() + words[n].slice(1);
    }
    return words.join(' ');
  }
}
  1. What would the resulting instance look like if we ran new Book("Shawshank Redemption", "Stephen King")?

  2. What about new Book("all the pretty horses", "cormac mccarthy")?

class Transaction {}
  1. What would happen if let transactions = new Transaction(14.50, new Date(), "Subway tickets") was run?

fewpjs-oo-predicting-constructor-effects-instrumental's People

Contributors

drakeltheryuujin avatar maxwellbenton avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fewpjs-oo-predicting-constructor-effects-instrumental's Issues

Quiz is improperly formatted - it has questions, but no answer options

Hi. This lesson says that it's a quiz, but there is no way to answer any of the questions.

Also, the part at the bottom is strange:

class Transaction {}
  1. What would happen if let transactions = new Transaction(14.50, new Date(), "Subway tickets") was run?

There's no code in the Transaction class, so that code would just return a blank Transaction object.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.