From 38f5c7938251a29ee6469b9a887725cc9dc31427 Mon Sep 17 00:00:00 2001 From: Fareaha Isnin Date: Mon, 15 Oct 2018 17:09:54 +0200 Subject: [PATCH 1/4] done --- starter-code/basic-algorithms.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/starter-code/basic-algorithms.js b/starter-code/basic-algorithms.js index 82f20d8ba..6c9420d84 100644 --- a/starter-code/basic-algorithms.js +++ b/starter-code/basic-algorithms.js @@ -1,7 +1,30 @@ // Names and Input +console.log("I'm Ready!"); +var hacker1 = "Fareaha".split('').join(' '); +hacker1 = hacker1.toUpperCase(); +console.log("The driver's name is " + hacker1); + +var hacker2 = prompt("What is your name?"); +var hacker2_1 = hacker2.split('').reverse().join(''); +console.log("The navigator's name is " + hacker2_1); -//Conditionals +//Conditionals +if (hacker1.length > hacker2.length){ + console.log("The Driver has the longest name, it has " + hacker1.length + " characters"); + } else if (hacker1 < hacker2.length){ + console.log("Yo, navigator got the longest name, it has " + hacker2.length + " characters"); + } else { + console.log("wow, you both got equally long names," + hacker1.length + " characters!!"); + } + + if (hacker1[0] < hacker2[0]){ + console.log("The driver's name goes first") + }else if (hacker2[0] > hacker1[0]){ + console.log("Yo, the navigator goes first definitely") + } else { + console.log("What?! You both got the same name?") + } // Lorem ipsum generator From 4798d68587246beb0ea4b18dff99c619d92289cb Mon Sep 17 00:00:00 2001 From: Fareaha Isnin Date: Mon, 15 Oct 2018 17:27:07 +0200 Subject: [PATCH 2/4] done --- starter-code/basic-algorithms.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/starter-code/basic-algorithms.js b/starter-code/basic-algorithms.js index 6c9420d84..7cc1d6bcd 100644 --- a/starter-code/basic-algorithms.js +++ b/starter-code/basic-algorithms.js @@ -16,7 +16,7 @@ if (hacker1.length > hacker2.length){ } else if (hacker1 < hacker2.length){ console.log("Yo, navigator got the longest name, it has " + hacker2.length + " characters"); } else { - console.log("wow, you both got equally long names," + hacker1.length + " characters!!"); + console.log("wow, you both got equally long names," + hacker1.length + " chsaracters!!"); } if (hacker1[0] < hacker2[0]){ @@ -27,4 +27,15 @@ if (hacker1.length > hacker2.length){ console.log("What?! You both got the same name?") } + //palindrom +var palindrome = prompt("Is it a palindrome?"); +var palindromeReverse = palindrome.split("").reverse().join(""); + +if (palindrom = palindromeReverse) { +console.log ("Yeah, It’s a palindrom!"); +}else{ + console.log ("Nope, Not a palindrome."); +} + + // Lorem ipsum generator From cb7b0d310e617b2d3eae1afa8093e311e23ace2c Mon Sep 17 00:00:00 2001 From: Fareaha Isnin Date: Mon, 15 Oct 2018 23:05:22 +0200 Subject: [PATCH 3/4] done --- starter-code/basic-algorithms.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/starter-code/basic-algorithms.js b/starter-code/basic-algorithms.js index 7cc1d6bcd..1be383fc5 100644 --- a/starter-code/basic-algorithms.js +++ b/starter-code/basic-algorithms.js @@ -39,3 +39,17 @@ console.log ("Yeah, It’s a palindrom!"); // Lorem ipsum generator +var paraIpsum = "Donec viverra sed velit a eleifend. Maecenas consectetur ullamcorper lacus sit amet consequat. Mauris eu venenatis purus. Mauris mattis nisl elit, nec interdum turpis pharetra a. Proin eu interdum ligula, efficitur rhoncus dolor. Suspendisse ut ante ante. Etiam ut tempus urna. Nulla pellentesque nisi ac quam pretium maximus eget molestie massa. Vivamus at maximus magna. Suspendisse aliquet pharetra lobortis. Nam ac diam tortor./Vestibulum molestie urna hendrerit, aliquam metus sed, dignissim turpis. Proin bibendum ipsum id convallis pretium. Donec placerat magna eget diam varius mollis. Mauris ac mauris a nisi imperdiet maximus. Praesent venenatis euismod porta. Aenean arcu elit, ultrices ac facilisis sit amet, ornare quis purus. Pellentesque vitae orci in dolor tincidunt ornare. In in pellentesque urna. Donec sit amet tellus ullamcorper, fringilla nibh a, sollicitudin sapien. Integer id bibendum urna. Nam nec dui luctus, varius enim a, hendrerit tortor. Nunc vitae tortor nec nunc gravida convallis quis quis lorem./Mauris non fermentum ipsum, in vulputate nisi. In hac habitasse platea dictumst. Sed a euismod velit, vitae sodales nibh. Nunc facilisis purus feugiat ligula cursus, quis ornare justo ultrices. Nullam volutpat, urna sed auctor feugiat, elit nisi rutrum sem, eu sodales massa neque in metus. Vestibulum ac lorem eu turpis sollicitudin maximus eget a purus. Etiam et commodo nulla, at vestibulum metus."; + +// Make your program count the number of words in the string +var wordCount = paraIpsum.split(" "); +console.log(wordCount.length); + +// Make your program count the number of times the latin word et appears + var counter = 0; + for (var i = 0; i < wordCount.length; i++) { + if (wordCount[i] === "et") { + counter ++; + } +} +console.log(counter); \ No newline at end of file From 0e072a5fe0f1ec7baccad974c98fec205be8ff1f Mon Sep 17 00:00:00 2001 From: Fareaha Isnin Date: Tue, 16 Oct 2018 11:00:15 +0200 Subject: [PATCH 4/4] done --- starter-code/basic-algorithms.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/starter-code/basic-algorithms.js b/starter-code/basic-algorithms.js index 1be383fc5..dbdad296e 100644 --- a/starter-code/basic-algorithms.js +++ b/starter-code/basic-algorithms.js @@ -28,13 +28,13 @@ if (hacker1.length > hacker2.length){ } //palindrom -var palindrome = prompt("Is it a palindrome?"); -var palindromeReverse = palindrome.split("").reverse().join(""); +var palindrom = prompt("Is it a palindrome?"); +var palindromReverse = palindrom.split("").reverse().join(""); -if (palindrom = palindromeReverse) { +if (palindrom === palindromReverse) { console.log ("Yeah, It’s a palindrom!"); }else{ - console.log ("Nope, Not a palindrome."); + console.log ("Nope, Not a palindrom."); } @@ -52,4 +52,5 @@ console.log(wordCount.length); counter ++; } } -console.log(counter); \ No newline at end of file +console.log(counter); +