-
Notifications
You must be signed in to change notification settings - Fork 10
week7 submission #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: Kursad-Ciftci
Are you sure you want to change the base?
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,57 @@ | ||
| //Question 1 | ||
| function sumOfThree (num1,num2,num3) { | ||
| return num1+num2+num3 | ||
| } | ||
|
|
||
| //Question 2 | ||
| function colorCar(x) { | ||
| return `a ${x} car` | ||
| } | ||
|
|
||
| //Question 3 | ||
| let person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"} | ||
|
|
||
| function objectPrinter(person) { | ||
| return (person) | ||
|
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 can also use a for...of loop to print out the properties and values from this object. |
||
| } | ||
|
|
||
| //Question 4 | ||
| function vehicleType (color,code) { | ||
| if (code == 1) { | ||
| return `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. This function should print out motorbike only if |
||
| return `a ${color} motorbike` | ||
| } | ||
| } | ||
|
|
||
| //Question 5 | ||
| let result = 3===3? "yes" : "No" | ||
| console.log(result) | ||
|
|
||
| //Question 6 | ||
| function vehicle (color,code,age) { | ||
| if (code == 1 && age>0) { | ||
| return `a ${color} used car` | ||
| } else if(code ==2 && age>0) { | ||
| return `a ${color} used motorbike` | ||
| }else if(code ==1 && age==0) { | ||
| return `a ${color} new 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. Similar comment to above - if I call this function with a |
||
| return `a ${color} new motorbike` | ||
| } | ||
| } | ||
|
|
||
| //Question 7 | ||
| listOfVehicles = ["motorbike", "caravan", "bike"] | ||
|
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 to use |
||
|
|
||
| //QUestion 8 | ||
| console.log(listOfVehicles[2]) | ||
|
|
||
| //Question 9 | ||
| function vehicleType (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. Nice work! |
||
| if (age > 0) { | ||
| return `a ${color} used ${listOfVehicles[code]}` | ||
| } else { | ||
| return `a ${color} new ${listOfVehicles[code]}` | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,25 @@ | ||
| // TODO: define addFavoriteBook(..) function | ||
| const favoriteBooks = []; | ||
|
|
||
| function addFavoriteBook (bookName) { | ||
| if (bookName.includes("Great")!== true) { | ||
|
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. Can you think of a shorter way to write this condition without having to use |
||
| favoriteBooks.push(bookName) | ||
| } | ||
| } | ||
|
|
||
| // TODO: define printFavoriteBooks() function | ||
|
|
||
| const favoriteBooks = []; | ||
| function printFavoriteBooks() { | ||
|
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. Right now, your function is only printing out the number of books, but it should also print out what's in the The for loop that you wrote on line 21 should also be included in the |
||
| console.log(`Favorite Books: ${favoriteBooks.length}`) | ||
| } | ||
|
|
||
| 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 | ||
| printFavoriteBooks() | ||
|
|
||
| for (let i of favoriteBooks) { | ||
| console.log(i) | ||
| } | ||
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 job!