From 1d737c3c949abd353d69e077e6218ec44ec288ef Mon Sep 17 00:00:00 2001 From: Andre Pires Date: Tue, 2 Sep 2025 20:48:37 +0100 Subject: [PATCH] Solved lab --- index.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 294f6b2..3fc467c 100644 --- a/index.js +++ b/index.js @@ -8,11 +8,11 @@ const s4 = "bread"; const s5 = "and"; // Concatenate the string variables into one new string - +const tongueTwister=`${s1} ${s2} ${s3} ${s4} ${s5} ${s3} ${s2} ${s1} ${s4}`; // Print out the concatenated string - - +console.log(tongueTwister); +console.log(tongueTwister==="Fred fed Ted bread and Ted fed Fred bread"); /******************************************* @@ -22,11 +22,12 @@ const part1 = "java"; const part2 = "script"; // Convert the last letter of part1 and part2 to uppercase and concatenate the strings +const newWord=`${part1.slice(0,part1.length-1)}${part1[part1.length-1].toUpperCase()}`+`${part2.slice(0,part2.length-1)}${part2[part2.length-1].toUpperCase()}` // Print the cameLtaiL-formatted string - - +console.log(newWord); +console.log(newWord==="javAscripT"); /******************************************* @@ -35,10 +36,10 @@ const part2 = "script"; const billTotal = 84; // Calculate the tip (15% of the bill total) - +const tipAmount=billTotal*0.15; // Print out the tipAmount - +console.log(tipAmount); @@ -47,10 +48,13 @@ const billTotal = 84; *******************************************/ // Generate a random integer between 1 and 10 (inclusive) +const minCeiled = Math.ceil(1); +const maxFloored = Math.floor(10); +const randomNumber=Math.floor(Math.random() * (maxFloored - minCeiled) + minCeiled); // Print the generated random number - +console.log(randomNumber); /******************************************* @@ -62,15 +66,22 @@ const b = false; // Try and guess the output of the below expressions first and write your answers down: const expression1 = a && b; +console.log(expression1===false); const expression2 = a || b; +console.log(expression2===true); const expression3 = !a && b; +console.log(expression3===false); const expression4 = !(a && b); +console.log(expression4===true); const expression5 = !a || !b; +console.log(expression5===true); const expression6 = !(a || b); +console.log(expression6===false); -const expression7 = a && a; \ No newline at end of file +const expression7 = a && a; +console.log(expression7===true); \ No newline at end of file