Skip to content
Open
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
74 changes: 65 additions & 9 deletions ex.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,69 @@
// TODO: define addFavoriteBook(..) function

// TODO: define printFavoriteBooks() function

const favoriteBooks = [];

addFavoriteBook("A Song of Ice and Fire");
addFavoriteBook("The Great Gatsby");
addFavoriteBook("Crime & Punishment");
addFavoriteBook("Great Expectations");
function addFavoriteBook(bookName) {
if (!bookName.includes('Great')) {
favoriteBooks.push(bookName);
}
}
addFavoriteBook('A Song of Ice and Fire');
addFavoriteBook('The Great Gatsby');
addFavoriteBook('Crime & Punishment');
addFavoriteBook('Great Expectations');
addFavoriteBook("You Don't Know JS");
function printFavoriteBooks() {
console.log('Favorite Books: ' + favoriteBooks.length);
for (const i of favoriteBooks) {
console.log(i);
}
}
printFavoriteBooks();

function sumNumbers(no1, no2, no3) {
return no1 + no2 + no3;
}

function colorCar(color) {
console.log('a ' + color + ' car');
}

function printObject(items) {
console.log(JSON.stringify(items));
}

function vehicleType(color, code) {
if (code === 1) {
console.log('a ' + color + ' car');
} else {
console.log('a ' + color + ' motorbike');
}

console.log(3 === 3 ? 'yes' : 'no');
}

function vehicle(color, code, age) {
if (code === 1) {
console.log('a ' + color + ' used car');
} else {
console.log('a ' + color + ' used motorbike');
}
}

const listOfVehicles = [
'motorbike',
'caravan',
'bike',
'car',
'bus',
'train',
'plain'
];

function printThirdItem() {
console.log(listOfVehicles[2]);
}

printThirdItem();

// TODO: print out favorite books
function vehicle(color, code, age) {
console.log('a ' + color + ' new ' + listOfVehicles[code - 1]);
}