Week 3 class assignment Joann Cahill#8
Week 3 class assignment Joann Cahill#8jcahill53 wants to merge 8 commits intoUW-JavaScript-310B:masterfrom
Conversation
|
|
||
| }; | ||
|
|
||
| logReceipt(); |
There was a problem hiding this comment.
Unfortunately by undoing the bit of boilerplate that tests the logReceipt() function we sort of lose our way as to what is being exercised. The implementation above has become brittle and not re-usable . . it's a one-use function that entirely relies upon some external state named items . . . What we're trying to get to is a function that can be passed any number of menu item objects (as the beginning file has as its test case)
Try again, and be sure that the logReceipt function can take an undetermined number of inputs . . . . remember the 'spread' operator!
| } | ||
|
|
||
| usetopSpeed(){ | ||
| const{name, topSpeed} = this; |
There was a problem hiding this comment.
Aha! Yes, this destructuring from this is a great strategy for methods, it makes them quite readable, BUT . . . . . .
|
|
||
| usetopSpeed(){ | ||
| const{name, topSpeed} = this; | ||
| console.log( `${this.name} moving to ${this.topSpeed}`) |
There was a problem hiding this comment.
if we don't use the destructured values, it becomes moot. You can probably see in VSCode that name and topSpeed on line 14 are kind of greyed out, or you can hove and see they are 'declared but never read' . . . . and that is because on line 15 you are accessing using this. .. . Now either way is totally valid, but it's a one-or-the-other kind of thing 😉
| // console.log(parsedPhone2); | ||
|
|
||
| //create format to be used in return statement | ||
| let phoneNumbers = (`areaCode: ${parsedAreaCode}, phoneNumber: ${parsedPhone2} `) |
There was a problem hiding this comment.
Very near the mark, but this is an important distinction . . . the goal is to return an object with the 2 values . . . here we are returning a string! I know it's a tad trivial seeming with this exercise, but having keen intentionality of types is a powerful skill to hone.
There was a problem hiding this comment.
refer to lines 75 and 78 for a glimpse of how the return value should look.
| // console.log(parsedPhone2); | ||
|
|
||
| //create format to be used in return statement | ||
| let phoneNumbers = (`areaCode: ${parsedAreaCode}, phoneNumber: ${parsedPhone2} `) |
There was a problem hiding this comment.
Also worth mentioning, this use of parenthesis around the string is not necessary
No description provided.