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 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy