-
Notifications
You must be signed in to change notification settings - Fork 10
done #10
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?
done #10
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| //1 | ||
| function sum(x,y,z){ | ||
| return (x+y+z); | ||
| }; | ||
|
|
||
|
|
||
| //2 | ||
| function colorCar (color){ | ||
| return `${color} car`; | ||
| }; | ||
|
|
||
| //3 | ||
| function printObj(obj){ | ||
| for( prop in obj){ | ||
| console.log(prop +" is "+obj[prop]); | ||
| } | ||
| } | ||
|
|
||
| //4 | ||
| function vehicleType(color,code){ | ||
| if(code == 1) | ||
| return `a ${color} car`; | ||
| if(code == 2) | ||
| return `a ${color} motorbike `; | ||
| }; | ||
|
|
||
| //5 c | ||
| console.log((3 === 3) ? "yes" : "no"); | ||
|
|
||
| //6 | ||
| function vehicle(color,code,age){ | ||
|
Collaborator
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. You haven't used your |
||
| if(code == 1) | ||
| return `a ${color} used car`; | ||
| if(code == 2) | ||
| return `a ${color} used motorbike `; | ||
| }; | ||
|
|
||
| //7 | ||
| let vehicles = ["motorbike","caravan","bike","suv"]; | ||
|
|
||
| //8 | ||
| vehicles[2]; | ||
| // | ||
| function vehicleType2(color,code,age){ | ||
| if(age > 1) | ||
| return `a ${color} used ${vehicles[code]}`; | ||
|
|
||
| return `a ${color} new ${vehicles[code]}`; | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,21 @@ | ||
| // TODO: define addFavoriteBook(..) function | ||
|
|
||
| // TODO: define printFavoriteBooks() function | ||
| function addFavoriteBook(bookName){ | ||
| if(!bookName.includes("Great")) | ||
| favoriteBooks.push(bookName); | ||
| } | ||
|
|
||
| const favoriteBooks = []; | ||
|
|
||
| addFavoriteBook("A Song of Ice and Fire"); | ||
| addFavoriteBook("The Great Gatsby"); | ||
| addFavoriteBook("Crime & Punishment"); | ||
| addFavoriteBook("Great Expectations"); | ||
| addFavoriteBook("You Don't Know JS"); | ||
|
|
||
| // TODO: print out favorite books | ||
|
|
||
| function printFavoriteBooks(){ | ||
| for(let i = 0; i<favoriteBooks.length; i++){ | ||
| console.log(`Your ${favoriteBooks.length } favorite books are : ${i+1}. ${favoriteBooks[i]}`) | ||
|
Collaborator
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. It's not really an issue, but I would just print out |
||
| } | ||
| } | ||
|
|
||
| printFavoriteBooks(); | ||
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.
Your function is well-written, but the question also asks you to create a sample object.