Skip to content

Instantly share code, notes, and snippets.

@appoll
Created March 2, 2022 18:52
Show Gist options
  • Save appoll/b948bec08826b4ed78c93e9d9c0bed17 to your computer and use it in GitHub Desktop.
Save appoll/b948bec08826b4ed78c93e9d9c0bed17 to your computer and use it in GitHub Desktop.
exercises.js
// objects can have arrays as properties
// E1. Let's find out how many bikes the user has
// 1.1 write one line of code to print how many bikes the user has
// 1.2 write a function that takes an user as parameter and returns the number of bikes the user has
let person = {
firstName: "Paul",
lastName: "Anton",
age: 28,
bikes: ["Mountain Bike", "Road Bike", "Cyclo Cross"],
minutesOnSocialMedia: [45, 55, 60, 120, 280, 900]
}
console.log(person.firstName)
console.log(person.age)
console.log(person.bikes)
// E2.
// 2.1 Add another property to the book object. e.g. language
// 2.2 Write a function that takes a book object as parameter and returns the book language.
// 2.3 Write a function that takes a book object as parameter prints the book details in the language in which the book is written:
// if the language of the book is "english", print the message in english:
// "The price of the book is ... and the title is ..."
// if the language of the book is "german", print the message in german
let book = {
title: "The Godfather",
price: 40,
currency: "USD"
}
function getBookLanguage(b){
}
function printBookDetails(b){
}
let language = getBookLanguage(book);
printBookDetails();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment