This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let b1 = { | |
title: "Gone with the wind", | |
price: 30, | |
currency: "EUR" | |
} | |
let b2 = { | |
title: "The godfather", | |
price: 40, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// E1 | |
// 1.1 Write a function that decreases the price of a book to half of its value | |
// 1.2 Write a function that converts a book's authors' last name to lowercase | |
// .toLower() | |
// 1.3 Write a function that converts a book's authors' last name to uppercase | |
// .toUpper() | |
let b1 = { | |
title: "Gone with the wind", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// text variables | |
customerName = "Florian"; | |
customerEmail = "[email protected]" | |
// numerical variables | |
customerAge = 25; | |
console.log("My name is: " + customerName); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We define a variable for the users' age; We want to check if they are over 18, in order to be able to drink beer or not; | |
// Print the following messages: "You are able to drink beer, since you were born in the year: 1992" OR | |
// "You are NOT able to drink beer, since you were born in the year: 2016" | |
if (age > 12){ | |
console.log("YES it is"); | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Uncomment the code between /* and */; | |
// Run the code; | |
// See what happens; | |
// Does it make sense? | |
// AND operator: && | |
// 3.1 | |
userName = "Siri" | |
if (3 > 1 && userName === "Siri"){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Uncomment the code between /* and */; | |
// Run the code; | |
// See what happens; | |
// Does it make sense? | |
// 1.0 | |
age = 18; | |
if (age == 18) { | |
console.log("1.0 Yes!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// E1. Print all even numbers between 10 and 20 (including 10 and 20). An even number is a number | |
// x for which the following is true: x % 2 === 0 | |
for (i = 10; i < 21; i++ ) { | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ages = [12, 16, 24, 98, 64, 24, 98, 64, 24, 98, 64] | |
// Print all the ages in your array :) | |
// We use the for loop | |
for (i = 0; i < ages.length; i = i + 1){ | |
currentAge = ages[i]; | |
console.log("Position is: " + i); | |
console.log("Value is: " + currentAge); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ages = [12, 16, 24, 28, 69, 14, 13, 80] | |
// E0. Copy all ages which are greater than 18 to a second array | |
largerThan18 = [] | |
for (i=0; i < ages.length; i++){ | |
} | |
console.log("Input: " + ages); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// E0. | |
// Write a function that prints the sum of two numbers. | |
// The 2 numbers should be passed in as parameters | |
// e.g. add(3,5) | |
function addNumbers(number1, number2){ | |
console.log("The sum is:..."); | |
} | |
addNumbers(10, 100); |