Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions answer.js
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){
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]}`;
};

16 changes: 12 additions & 4 deletions ex.js
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]}`)
}
}

printFavoriteBooks();