From fe964dac04639e774c2cc31852497cf36ba3277a Mon Sep 17 00:00:00 2001 From: David Bouhaben Date: Wed, 19 Nov 2025 15:07:04 +0100 Subject: [PATCH 1/2] lab-js-data-types finished --- index.js | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 294f6b2..310e6be 100644 --- a/index.js +++ b/index.js @@ -8,13 +8,11 @@ const s4 = "bread"; const s5 = "and"; // Concatenate the string variables into one new string - +let concatenateWords = `${s1} ${s2} ${s3} ${s4} ${s5}`; +console.log("Here is the concantenate words : ", concatenateWords); // Print out the concatenated string - - - /******************************************* Iteration 1.2 | Camel Tail *******************************************/ @@ -22,37 +20,47 @@ const part1 = "java"; const part2 = "script"; // Convert the last letter of part1 and part2 to uppercase and concatenate the strings - +const concatenateWords1 = + part1 + + part1[part1.length - 1].toUpperCase() + + " " + + part2 + + part2[part2.length - 1].toUpperCase(); +console.log( + "This is concantenated words with each last letter capitalize : ", + concatenateWords1 +); // Print the cameLtaiL-formatted string - - - /******************************************* Iteration 2.1 | Calculate Tip *******************************************/ const billTotal = 84; // Calculate the tip (15% of the bill total) - +const percentageTip = 15 / 100; +const totalTip = billTotal * percentageTip; +console.log( + "The total tip of the bil total of " + + billTotal + + " euros is " + + totalTip + + " euros" +); // Print out the tipAmount - - - /******************************************* Iteration 2.2 | Generate Random Number *******************************************/ // Generate a random integer between 1 and 10 (inclusive) +let randomNumber = Math.floor(Math.random() * 10) + 1; - +console.log(`The random number between 1 and 10 is ${randomNumber}`); // Print the generated random number - - /******************************************* Iteration 3.1 | Booleans *******************************************/ @@ -62,15 +70,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(`The output of the expression of ${expression1} is false`); const expression2 = a || b; +console.log(`The output of the expression of ${expression2} is true`); const expression3 = !a && b; +console.log(`The output of the expression of ${expression3} is false`); const expression4 = !(a && b); +console.log(`The output of the expression of ${expression4} is true`); const expression5 = !a || !b; +console.log(`The output of the expression of ${expression5} is true`); const expression6 = !(a || b); +console.log(`The output of the expression of ${expression6} is false`); -const expression7 = a && a; \ No newline at end of file +const expression7 = a && a; +console.log(`The output of the expression of ${expression7} is true`); From 97bd23aa708777f4482094c5119e8277fe0d2f53 Mon Sep 17 00:00:00 2001 From: David Bouhaben Date: Wed, 19 Nov 2025 15:21:04 +0100 Subject: [PATCH 2/2] better result! Final --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index 310e6be..530e8bd 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,7 @@ const s4 = "bread"; const s5 = "and"; // Concatenate the string variables into one new string -let concatenateWords = `${s1} ${s2} ${s3} ${s4} ${s5}`; +let concatenateWords = `${s1} ${s2} ${s3} ${s4} ${s5} ${s3} ${s1} ${s4}`; console.log("Here is the concantenate words : ", concatenateWords); // Print out the concatenated string @@ -23,7 +23,6 @@ const part2 = "script"; const concatenateWords1 = part1 + part1[part1.length - 1].toUpperCase() + - " " + part2 + part2[part2.length - 1].toUpperCase(); console.log(