From 2eaf7b7d51b2ea7a20ee0e6faa855abaf49b241f Mon Sep 17 00:00:00 2001 From: Alix de Ribet Date: Thu, 9 Jan 2020 09:33:23 +0100 Subject: [PATCH] done --- js/index.js | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 3 deletions(-) diff --git a/js/index.js b/js/index.js index dd8ff0062..cbb275315 100644 --- a/js/index.js +++ b/js/index.js @@ -1,7 +1,106 @@ -// Iteration 1: Names and Input +// ITERATION 1 +var hacker1 = "Alix"; +console.log(`The driver's name is ${hacker1}.`); +var hacker2 = "PaulC"; +console.log(`The navigator's name is ${hacker2}.`); -// Iteration 2: Conditionals +// ITERATION 2 + +if (hacker1.length > hacker2.length) { + console.log(`The driver has the longest name, it has ${hacker1.length} characters.`); +} else if (hacker1.length < hacker2.length) { + console.log(`It seems that the navigator has the longest name, it has ${hacker2.length} characters.`); +} else { + console.log(`Wow, you both have equally long names, ${hacker1.length} characters!`); +}; + +// ITERATION 3 + +var newHacker1 = ""; +for (let i=0; i-1; i--) { + newHacker2 += hacker2[i]; +}; +console.log(newHacker2); + +//ITERATION 4 (1/2) + +hacker1 = "Jean"; +hacker2 = "Jeannine"; + +for(let i=0; i hacker2[i]) { + console.log("Yo, the navigator goes first definitely."); + break; + } else if (hacker1[i] === hacker2[i]) { + if (i === Math.min(hacker1.length, hacker2.length)-1) { + if (hacker1.length < hacker2.length) { + console.log("The driver's name goes first"); + break; + } else if (hacker2.length < hacker1.length){ + console.log("Yo, the navigator goes first definitely."); + break; + } else if (hacker2.length === hacker1.length) { + console.log("What?! You both have the same name?"); + break; + }; + }; + }; +}; + +// ITERATION 4 (2/2) + +hacker1.toLowerCase(); +hacker2.toLowerCase(); + +let i = 0; + +while (i hacker2[i]) { + console.log("Yo, the navigator goes first definitely."); + break; + } else { + i++; + } +} + +if (hacker1.length < hacker2.length) { + console.log("the driver's name comes first"); +} else { + console.log("the navigator's name comes first"); +} + + + + + + + + + + + + + +Envoyer un message à Paul Carillion + + +À propos de cette conversation -// Iteration 3: Loops \ No newline at end of file