week 7 homework#13
Conversation
epq
left a comment
There was a problem hiding this comment.
Overall, you did a great job. If there are concepts you would still like to review, please ask!
| var p1 = 6; | ||
| var p2 = 7; | ||
| var p3 = 10; | ||
| function tripleFunction (p1,p2,p3) { |
| // 2.answer | ||
|
|
||
| function colorCar(color){ | ||
| console.log( 'a' +''+ color +''+ 'car'); |
There was a problem hiding this comment.
This is good but the output doesn't have spaces. If you want to put spaces, you need to use a space in your string ' ' instead of ''.
| if (code === 1){ | ||
| console.log('a'+ color + 'car') | ||
| } | ||
| else { |
There was a problem hiding this comment.
Motorbike should only print out if the code is 2. What will this function print out if you call it with values other than 1 or 2?
| function vehicle(color,age,code){ | ||
|
|
||
| if (age <= 1){ | ||
| console.log('a'+ color + 'new' + code); |
There was a problem hiding this comment.
make sure your output has spaces so it's easily readable! You can add spaces like this:
console.log('a '+ color + ' new ' + code);| if (age <= 1){ | ||
| console.log('a'+ color + 'new' + code); | ||
| }else if(age >1){ | ||
| console.log('a'+''+ color +''+ 'used' +''+ code); |
There was a problem hiding this comment.
Same comment as above regarding spaces. You should use ' ' to add a space instead of ''.
| //6.answer | ||
|
|
||
| let code = ["car" , "motorbike"] | ||
| function vehicle(color,age,code){ |
There was a problem hiding this comment.
I think you combined questions 6 and 9 but that's okay!
Question 9 involves writing a function with three parameters, color, age, and code. code should be a number (array index) that you use to get the value from an array. It shouldn't be the actual element from the array.
For example, you are calling your function like this:
vehicle("blue", 3 , code[0]); // the third parameter, code[0], is the string "car" from your array on line 57The function should be called like this:
vehicle("blue", 3, 0); // the third parameter is a number (array index)Then in the function, you should use the array index to get the vehicle type from the array.
| // TODO: define printFavoriteBooks() function | ||
|
|
||
| function printFavoriteBooks(){ | ||
| console.log('There are' + favoriteBooks.length + 'favorite books.'); |
There was a problem hiding this comment.
Well done! Just make sure to add spaces in your output. 😄
I apologize for late homework. I needed to do some subject repeat for answers to get everything clear.