-
Notifications
You must be signed in to change notification settings - Fork 10
week 7 homework #13
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: Elif-Sude-Yasar
Are you sure you want to change the base?
week 7 homework #13
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,80 @@ | ||
| // 1.answer | ||
|
|
||
| var p1 = 6; | ||
| var p2 = 7; | ||
| var p3 = 10; | ||
| function tripleFunction (p1,p2,p3) { | ||
| return p1 + p2 + p3 | ||
| } | ||
|
|
||
| tripleFunction(p1,p2,p3); | ||
|
|
||
| // 2.answer | ||
|
|
||
| function colorCar(color){ | ||
| console.log( 'a' +''+ color +''+ 'car'); | ||
|
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. 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 |
||
| } | ||
|
|
||
| colorCar("red"); | ||
|
|
||
| //3.answer | ||
|
|
||
| const aboutMe ={ | ||
| name : 'Elif', | ||
| surname : 'Yasar', | ||
| age: '19', | ||
| nationality: 'Turkish', | ||
| address: { | ||
| street: 'Hello Street', | ||
| city: 'Toronto' | ||
| }, | ||
| } | ||
|
|
||
| function learnAboutMe(){ | ||
| console.log(aboutMe); | ||
| } | ||
|
|
||
| learnAboutMe(); | ||
|
|
||
| // 4.answer | ||
|
|
||
| function vehcileType(color,code){ | ||
| if (code === 1){ | ||
| console.log('a'+ color + 'car') | ||
| } | ||
| else { | ||
|
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. Motorbike should only print out if the |
||
| console.log('a'+ color + 'motorbike') | ||
| } | ||
| } | ||
| vehcileType('blue', 1); | ||
|
|
||
| //5.answer | ||
|
|
||
| console.log(3 === 3 ? 'yes' : 'no'); | ||
|
|
||
| //6.answer | ||
|
|
||
| let code = ["car" , "motorbike"] | ||
| function vehicle(color,age,code){ | ||
|
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. I think you combined questions 6 and 9 but that's okay! 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. |
||
|
|
||
| if (age <= 1){ | ||
| console.log('a'+ color + 'new' + code); | ||
|
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. make sure your output has spaces so it's easily readable! You can add spaces like this: console.log('a '+ color + ' new ' + code); |
||
| }else if(age >1){ | ||
| console.log('a'+''+ color +''+ 'used' +''+ code); | ||
|
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. Same comment as above regarding spaces. You should use |
||
| } | ||
|
|
||
| } | ||
| vehicle("blue", 3 , code[0] ) | ||
|
|
||
|
|
||
| //7.answer | ||
|
|
||
| let listOfVehicles = ["motorbike", "caravan", "bike", "car","ship", "plane",] | ||
|
|
||
|
|
||
| //8.answer | ||
| console.log(listOfVehicles[2]); | ||
|
|
||
| //9.answer | ||
|
|
||
| vehicle("green",1,listOfVehicles[2]); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| // TODO: define addFavoriteBook(..) function | ||
|
|
||
| // TODO: define printFavoriteBooks() function | ||
|
|
||
| const favoriteBooks = []; | ||
|
|
||
| addFavoriteBook("A Song of Ice and Fire"); | ||
|
|
@@ -10,4 +8,21 @@ addFavoriteBook("Crime & Punishment"); | |
| addFavoriteBook("Great Expectations"); | ||
| addFavoriteBook("You Don't Know JS"); | ||
|
|
||
| function addFavoriteBook(bookName) { | ||
| if (!bookName.includes('Great')){ | ||
| favoriteBooks.push(bookName); | ||
| } | ||
| } | ||
| console.log(favoriteBooks); | ||
|
|
||
| // TODO: define printFavoriteBooks() function | ||
|
|
||
| function printFavoriteBooks(){ | ||
| console.log('There are' + favoriteBooks.length + 'favorite books.'); | ||
|
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. Well done! Just make sure to add spaces in your output. 😄 |
||
| for (let favbooks of favoriteBooks){ | ||
| console.log(favbooks); | ||
| } | ||
| } | ||
|
|
||
| // TODO: print out favorite books | ||
| printFavoriteBooks(favoriteBooks); | ||
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.
Good work!