This file contains 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
console.log('----------new map--------------'); | |
const question = new Map([ | |
['question', 'What is the best programming language in the world'], | |
[1, 'C'], | |
[2, 'Java'], | |
[3, 'JavaScript'], | |
['correct', 3], | |
[true, 'Correct 😊'], | |
[false, 'try again'], |
This file contains 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
// maps are more useful then sets | |
// maps have key-value pairs | |
// maps keys can have any type | |
const restaurantMap = new Map(); | |
restaurantMap.set('name', "Vini's Curry House"); | |
restaurantMap.set(1, 'Mumbai, India'); | |
console.log(restaurantMap.set(2, 'Paris, France')); |
This file contains 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
// sets have no order and only store unique items. | |
// no need to get data out of a set | |
const ordersSet = new Set(['Pasta', 'Pizza', 'Risotto', 'Pasta', 'Pizza']); | |
console.log(ordersSet); | |
console.log(new Set('Vini')); |
This file contains 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
const weekDays = ['mon', 'tues', 'wed', 'thu', 'fri', 'sat', 'sun']; | |
const openingHours = { | |
[weekDays[3]]: { | |
open: 12, | |
close: 22, | |
}, | |
fri: { | |
open: 11, | |
close: 23, |
This file contains 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
'use strict'; | |
const weekDays = ['mon', 'tues', 'wed', 'thu', 'fri', 'sat', 'sun']; | |
const openingHours = { | |
[weekDays[3]]: { | |
open: 12, | |
close: 22, | |
}, | |
fri: { |
This file contains 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
'use strict'; | |
// Data needed for a later exercise | |
const flights = | |
'_Delayed_Departure;fao93766109;txl2133758440;11:25+_Arrival;bru0943384722;fao93766109;11:45+_Delayed_Arrival;hel7439299980;fao93766109;12:05+_Departure;fao93766109;lis2323639855;12:30'; | |
// Data needed for first part of the section | |
const restaurant = { | |
name: "Vini's Curry House", | |
location: '123 Gora Way, Mumbai, India', | |
categories: ['Punjabi', 'Bengali', 'Madras', 'Neplai'], |
This file contains 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
'use strict'; | |
// Data needed for a later exercise | |
const flights = | |
'_Delayed_Departure;fao93766109;txl2133758440;11:25+_Arrival;bru0943384722;fao93766109;11:45+_Delayed_Arrival;hel7439299980;fao93766109;12:05+_Departure;fao93766109;lis2323639855;12:30'; | |
// Data needed for first part of the section | |
const restaurant = { | |
name: "Vini's Curry House", | |
location: '123 Gora Way, Mumbai, India', |
This file contains 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
// functions REST | |
const add = function (...numbers) { | |
let sum = 0; | |
for (let i = 0; i < numbers.length; i++) sum += | |
numbers[i]; | |
console.log(sum); | |
}; | |
add(2, 3); | |
add(5, 6, 7, 8, 9); |
This file contains 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
// CODE CHALLENGE | |
// Given an array of forecasted maximum temperatures, the thermometer displays a | |
// string with the given temperatures. Example: [17, 21, 23] will print "... 17ºC in 1 | |
// days ... 21ºC in 2 days ... 23ºC in 3 days ..." | |
// Your tasks: | |
// 1. Create a function 'printForecast' which takes in an array 'arr' and logs a | |
// string like the above to the console. Try it with both test datasets. | |
// 2. Use the problem-solving framework: Understand the problem and break it up | |
// into sub-problems! |
This file contains 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
const ginaArr = [ | |
'Gina', | |
'Davis', | |
2037 - 1967, | |
'singer', | |
['Sam', 'Tam', 'Mam'], | |
]; | |