From 56add446bdeb303cdc527e5fa36d72aeb0e8a10f Mon Sep 17 00:00:00 2001 From: carliitosway-collab Date: Wed, 12 Nov 2025 15:19:32 +0100 Subject: [PATCH] Solved lab --- index.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 294f6b2..eb70a0e 100644 --- a/index.js +++ b/index.js @@ -8,10 +8,11 @@ const s4 = "bread"; const s5 = "and"; // Concatenate the string variables into one new string - +const sentence = `${s1} ${s2} ${s3} ${s5} ${s4}`; +console.log(sentence) // Print out the concatenated string - +"Fred fed Ted and bread" @@ -20,12 +21,12 @@ const s5 = "and"; *******************************************/ const part1 = "java"; const part2 = "script"; - // Convert the last letter of part1 and part2 to uppercase and concatenate the strings - +const camelTail = part1.slice(0, -1) + part1.slice(-1).toUpperCase() + part2.charAt(0).toUpperCase() + part2.slice(1); +console.log(camelTail);; // Print the cameLtaiL-formatted string - +"javAScript" @@ -35,9 +36,11 @@ const part2 = "script"; const billTotal = 84; // Calculate the tip (15% of the bill total) - +const tipAmount = billTotal * 0.15; +console.log("tip:", tipAmount); // Print out the tipAmount +"tip:" 12.6 @@ -47,10 +50,11 @@ const billTotal = 84; *******************************************/ // Generate a random integer between 1 and 10 (inclusive) - +const randomNumber = Math.floor(Math.random() * 10) + 1; +console.log(randomNumber); // Print the generated random number - +6 /******************************************* @@ -62,15 +66,16 @@ const b = false; // Try and guess the output of the below expressions first and write your answers down: const expression1 = a && b; - +// true && false = false const expression2 = a || b; - +// true || false = true const expression3 = !a && b; - +// !true && false = false && false = false const expression4 = !(a && b); - +// !(true && false) = !(false) = true const expression5 = !a || !b; - +// !true || !false = false || true = true const expression6 = !(a || b); - -const expression7 = a && a; \ No newline at end of file +// !(true || false) = !(true) = false +const expression7 = a && a; +// true && true = true \ No newline at end of file