-
Notifications
You must be signed in to change notification settings - Fork 21
Week 3 class assignment Joann Cahill #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
1c108fe
ca66bb8
fd03493
97801bc
f8d7569
08e71ec
2428c05
9150d4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,22 @@ | |
// - should have a method accelerate that logs to the console | ||
// `${name} moving to ${topSpeed}` | ||
|
||
class SpaceShip { | ||
constructor(name, topSpeed) { | ||
this.name = name; | ||
this.topSpeed = topSpeed; | ||
|
||
} | ||
usetopSpeed(){ | ||
const{name, topSpeed} = this; | ||
console.log( `${this.name} moving to ${this.topSpeed}`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we don't use the destructured values, it becomes moot. You can probably see in VSCode that |
||
} | ||
|
||
} | ||
|
||
|
||
// 2. Call the constructor with a couple ships, | ||
// and call accelerate on both of them. | ||
|
||
const spaceX = new SpaceShip('SpaceXShip', '500 mph'); | ||
spaceX.usetopSpeed()+; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha! Yes, this destructuring from
this
is a great strategy for methods, it makes them quite readable, BUT . . . . . .