diff --git a/4. Practice time - part 2/2. if else/index.js b/4. Practice time - part 2/2. if else/index.js index 7eabce28..bf55c444 100644 --- a/4. Practice time - part 2/2. if else/index.js +++ b/4. Practice time - part 2/2. if else/index.js @@ -1,4 +1,4 @@ -let age = 15 +let age = 15; // less than 6 years old -> free // 6 to 17 years old -> child discount @@ -7,4 +7,19 @@ let age = 15 // over 66 years old -> senior citizen discount // Create a conditional statement (if/else/else if) that logs out the discount -// the passenger will get based upon the value of the age variable \ No newline at end of file +// the passenger will get based upon the value of the age variable +const pricing = () => { + age < 6 + ? console.log("free") + : age >= 6 && age <= 17 + ? console.log("child discount") + : age >= 18 && age <= 26 + ? console.log("student discount") + : age >= 27 && age <= 66 + ? console.log("full price") + : age > 66 + ? console.log("senior citizen discount") + : null; +}; + +console.log(pricing()); diff --git a/4. Practice time - part 2/3. Loops and arrays/index.js b/4. Practice time - part 2/3. Loops and arrays/index.js index 8ace5085..5e1ed02d 100644 --- a/4. Practice time - part 2/3. Loops and arrays/index.js +++ b/4. Practice time - part 2/3. Loops and arrays/index.js @@ -1,4 +1,4 @@ -let largeCountries = ["China","India","USA","Indonesia","Pakistan"] +let largeCountries = ["China", "India", "USA", "Indonesia", "Pakistan"]; /* Use a for loop to log the following to the console: @@ -6,6 +6,10 @@ The 5 largest countries in the world: - China - India - United States -- Indinesia +- Indonesia - Pakistan -*/ +*/ console.log("The 5 largest countries in the world: "); + +for (let i = 0; i < largeCountries.length; i++) { + console.log("- " + largeCountries[i]); +} diff --git a/4. Practice time - part 2/4. push, pop, unshift, shift challenge/index.js b/4. Practice time - part 2/4. push, pop, unshift, shift challenge/index.js index fa50a31a..fc11ed7a 100644 --- a/4. Practice time - part 2/4. push, pop, unshift, shift challenge/index.js +++ b/4. Practice time - part 2/4. push, pop, unshift, shift challenge/index.js @@ -1,7 +1,14 @@ -let largeCountries = ["Tuvalu","India","USA","Indonesia","Monaco"] +let largeCountries = ["Tuvalu", "India", "USA", "Indonesia", "Monaco"]; -// You need to help me fixup the largeCountries array so that +// You need to help me fixup the largeCountries array so that // China and Pakistan are added back into their respective places // Use push() & pop() and their counterparts unshift() & shift() // Google how to use unshift() and shift() + +largeCountries.pop(); +largeCountries.push("Pakistan"); +largeCountries.shift(); +largeCountries.unshift("China"); + +console.log(largeCountries); diff --git a/4. Practice time - part 2/5. Logical operators/index.js b/4. Practice time - part 2/5. Logical operators/index.js index eb0d1930..ff04a11d 100644 --- a/4. Practice time - part 2/5. Logical operators/index.js +++ b/4. Practice time - part 2/5. Logical operators/index.js @@ -1,8 +1,7 @@ -let dayOfMonth = 13 -let weekday = "Friday" +let dayOfMonth = 13; +let weekday = "Friday"; // If it is Friday the 13th, log out this spooky face: 😱 // Use the logical "AND operator" -> && - - +dayOfMonth && weekday ? console.log("😱") : null; diff --git a/4. Practice time - part 2/6. Rock papers scissors/index.js b/4. Practice time - part 2/6. Rock papers scissors/index.js index dc4958f6..198ede12 100644 --- a/4. Practice time - part 2/6. Rock papers scissors/index.js +++ b/4. Practice time - part 2/6. Rock papers scissors/index.js @@ -1,5 +1,9 @@ -let hands = ["rock", "paper", "scissor"] +let hands = ["rock", "paper", "scissor"]; // Create a function that returns a random item from the array - +const getRamdomItem = () => { + let ramdomItem = Math.floor(Math.random() * 3); + console.log(hands[ramdomItem]); +}; +getRamdomItem(); diff --git a/4. Practice time - part 2/7. Sorting fruits/index.html b/4. Practice time - part 2/7. Sorting fruits/index.html index 9c16372b..d0ffa330 100644 --- a/4. Practice time - part 2/7. Sorting fruits/index.html +++ b/4. Practice time - part 2/7. Sorting fruits/index.html @@ -3,8 +3,8 @@
- - +