From 12d157ba3849bffb24d5bb6efeaa44271c7d4d52 Mon Sep 17 00:00:00 2001 From: Wilson Cruz Date: Mon, 10 Feb 2020 22:08:00 +0000 Subject: [PATCH 1/5] stopped at iteration 3 --- lab.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lab.js diff --git a/lab.js b/lab.js new file mode 100644 index 000000000..070aff897 --- /dev/null +++ b/lab.js @@ -0,0 +1,31 @@ +// Iteration 1 +let hacker1 = 'Wilson'; +console.log(hacker1); + +let hacker2 = 'Diogo'; +console.log(hacker2); + +// Iteration 2 +if(hacker1.length > hacker2.length){ + console.log(`The driver has the longest name, is 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 + + // 3.1 Print all the characters of the driver's name, separated by a space and in capitals i.e. "J O H N" +let a= '' +for (let i = 0; i < hacker1.length; i++) { + a += hacker1[i].toUpperCase() + ' '; +} +console.log(a); + + // 3.2 Print all the characters of the navigator's name, in reverse order. i.e. "nhoJ" +// let b= '' +// for (let i >= 0; i < hacker2.length; i--) { +// b += hacker2[i]; +// } +// console.log(b); \ No newline at end of file From b459cb9f3896b32a2ac308f228fdc63685ccf141 Mon Sep 17 00:00:00 2001 From: Wilson Cruz Date: Wed, 12 Feb 2020 00:14:32 +0000 Subject: [PATCH 2/5] Done! --- js/index.js | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++- lab.js | 13 ----------- 2 files changed, 64 insertions(+), 14 deletions(-) diff --git a/js/index.js b/js/index.js index dd8ff0062..d6b58b878 100644 --- a/js/index.js +++ b/js/index.js @@ -1,7 +1,70 @@ // Iteration 1: Names and Input +let hacker1 = 'Wilson'; +console.log(hacker1); +let hacker2 = 'Diogo'; +console.log(hacker2); // Iteration 2: Conditionals +if(hacker1.length > hacker2.length){ + console.log(`The driver has the longest name, is 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: Loops -// Iteration 3: Loops \ No newline at end of file + // 3.1 Print all the characters of the driver's name, separated by a space and in capitals i.e. "J O H N" + let a= ''; + for (let i = 0; i < hacker1.length; i++) { + a += hacker1[i].toUpperCase() + ' '; + } + console.log(a); + + // 3.2 Print all the characters of the navigator's name, in reverse order. i.e. "nhoJ" + let b= ''; + for (let i = hacker2.length; i >= 0; i--) { + b += hacker2[i]+' '; + } + console.log(b); + + // 3.3 + if (hacker1>hacker2) { + console.log(`The driver's name goes first.`) + }else if (hacker1 hacker2.length){ // Iteration 3 - // 3.1 Print all the characters of the driver's name, separated by a space and in capitals i.e. "J O H N" -let a= '' -for (let i = 0; i < hacker1.length; i++) { - a += hacker1[i].toUpperCase() + ' '; -} -console.log(a); - - // 3.2 Print all the characters of the navigator's name, in reverse order. i.e. "nhoJ" -// let b= '' -// for (let i >= 0; i < hacker2.length; i--) { -// b += hacker2[i]; -// } -// console.log(b); \ No newline at end of file From 0be20190bc0d9fb3555e7df317de5f5d9fe059b5 Mon Sep 17 00:00:00 2001 From: galatoide Date: Wed, 12 Feb 2020 00:17:16 +0000 Subject: [PATCH 3/5] Delete lab.js --- lab.js | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 lab.js diff --git a/lab.js b/lab.js deleted file mode 100644 index 598a61dc8..000000000 --- a/lab.js +++ /dev/null @@ -1,18 +0,0 @@ -// Iteration 1 -let hacker1 = 'Wilson'; -console.log(hacker1); - -let hacker2 = 'Diogo'; -console.log(hacker2); - -// Iteration 2 -if(hacker1.length > hacker2.length){ - console.log(`The driver has the longest name, is 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 - From ff4ed7641992fac667d40ba38e478a0f83829ee4 Mon Sep 17 00:00:00 2001 From: Wilson Cruz Date: Wed, 12 Feb 2020 17:48:22 +0000 Subject: [PATCH 4/5] Iteration 3.3 changed for better, bonus 2 solution added. --- js/index.js | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/js/index.js b/js/index.js index d6b58b878..3c95509f6 100644 --- a/js/index.js +++ b/js/index.js @@ -31,13 +31,23 @@ if(hacker1.length > hacker2.length){ console.log(b); // 3.3 - if (hacker1>hacker2) { - console.log(`The driver's name goes first.`) - }else if (hacker1hacker2) { + // console.log(`The driver's name goes first.`) + // }else if (hacker10) { + console.log(`The driver's name goes first.`) + }else if (hacker1.localeCompare(hacker2)<0){ + console.log('Yo, the navigator goes first definitely.') + }else { + console.log('What?! You both have the same name?') + } + // Bonus 1 !! let lorem = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras bibendum eros sit amet purus consequat, a egestas mauris maximus. Duis imperdiet, ante vel vulputate ornare, ante ante fringilla odio, eget iaculis mi turpis ac tortor. Curabitur quis commodo nisl. Aliquam rutrum neque gravida odio malesuada sagittis. Proin magna lorem, laoreet ut auctor non, lacinia vel lorem. Ut nec interdum quam, in dictum tortor. Proin aliquet, est at vehicula pharetra, orci leo pellentesque libero, a fermentum metus nisl nec diam. Nullam feugiat lacinia metus quis mollis. @@ -67,4 +77,28 @@ console.log(countEt) // } -// got stuck thinking about this one \ No newline at end of file +// got stuck thinking about this one + + // Paula's solution that I have to check + // //change around phraseToCheck to text results + // const phraseToCheck = "Amor, Roma"; + + // // 1st Remove spaces from String + // let removedSpaces = ""; + // for(i= 0; i < phraseToCheck.length; i++){ + // if(phraseToCheck[i] === " "){ + // continue + // } else { + // removedSpaces += phraseToCheck[i].toLowerCase() + // } + // } + // // 2nd compare every index from front with every index from end + // let output = "" + // for(i = 0; i < removedSpaces.length; i++) { + // if(removedSpaces[i] === removedSpaces[removedSpaces.length-1-i]) { + // output = `${phraseToCheck} is a Palindrome. :) ` + // } else { + // output = `${phraseToCheck} is not a Palindrome. :( ` + // break } + // } + // console.log("Bonus 2: ",output) \ No newline at end of file From 325de67e2693ec92d1d1babdb6e9171896ef6315 Mon Sep 17 00:00:00 2001 From: Wilson Cruz Date: Wed, 12 Feb 2020 17:52:27 +0000 Subject: [PATCH 5/5] Iteration 3.3 changed for better, bonus 2 solution added. --- js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index 3c95509f6..316ac2547 100644 --- a/js/index.js +++ b/js/index.js @@ -101,4 +101,4 @@ console.log(countEt) // output = `${phraseToCheck} is not a Palindrome. :( ` // break } // } - // console.log("Bonus 2: ",output) \ No newline at end of file + // console.log("Bonus 2: ",output) \ No newline at end of file