From e38ef44d123da1f9ff0b5ebdbe9a7c526e708dab Mon Sep 17 00:00:00 2001 From: katros Date: Mon, 30 Jul 2018 15:26:02 +0200 Subject: [PATCH 1/2] Until 8 done --- .DS_Store | Bin 0 -> 6148 bytes starter-code/basic-algorithms.js | 38 ++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3eae0c53c8c8fe6c2267a6568a390cc8168e859d GIT binary patch literal 6148 zcmeHK-D=c86h5=vYT}AS5L&^DfERkPmbKcJ;!Rw41wm1oVlVtzlV<1!Vx}as-HT-* z_y9gYduuDchWZe`h}U}NXN7DncqJm|z|42%%=u2pm)-dR0M;EPw*fo=aIh(CxY+&1 z)Vyk^tYIUIh)mUZl!@Iq6ETieL9%~e0rl;gumXFKf}Hz)_i*m!4{iEIT-bs>+=m`K zL0o~ikjybY%`q-Q2@)bGu;zmWIKiSymwEeqx)~8d~ajxEYxb=GU?)~A>hvSovpTB4pF#J1dyKHd=U(q>J z)Pu0dGm-CM&Wu0f5t0I=04Y#Yz%CL_s}`jJDL@L40_G6mqY!GH2rO0x_0oZzz5*aN zF{}-Jee_54RRA%tSQ*3!8Z%TxLuK}g!R*a}89L4fHor1x=)m-ov5tK*vo{oGFCNU- z>A(Vm)RO|FKwW_aGxXH{-#`2QUnkLs6d(ouD+O4y7xudNN_KBO^>S*j^|8IdrcC8k n27gh|(OWU*s;zh#n>LL5%0Ub)Rt7PGMh5{c19hapUsd2Iw6u&l literal 0 HcmV?d00001 diff --git a/starter-code/basic-algorithms.js b/starter-code/basic-algorithms.js index 82f20d8ba..2fc0d2727 100644 --- a/starter-code/basic-algorithms.js +++ b/starter-code/basic-algorithms.js @@ -1,7 +1,39 @@ -// Names and Input +//var hacker1 = prompt("What is the driver's name?"); +var hacker1 = "Tom"; +console.log("The driver's name is " + hacker1); +//var hacker2 = prompt("What is the navigator's name?"); +var hacker2 = "Benjamin"; +console.log("The navigator's name is " + hacker2); -//Conditionals +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("Yo, navigator got the longest name, it has " + hacker2.length + " characters") +} else { + console.log("Wow, you both got equally long names, " + hacker1.length + " characters") +} +var driversName = ""; -// Lorem ipsum generator +for (var i = 0; i < hacker1.length; i++){ + driversName += hacker1[i].toUpperCase(); + driversName += " "; +} +console.log(driversName); + +var navigatorsName = ""; + +for (var i = hacker2.length - 1; i >= 0; i--){ + navigatorsName += hacker2[i]; +} +console.log(navigatorsName); + + +if (hacker1[0] > hacker2[0]){ + console.log("The driver's name goes first"); +} else if (hacker1[0] < hacker2[0]){ + console.log("Yo, the navigator goes firs definitely") +} else { + console.log("What?! You both got the same name?"); +} From 898b0429965fff88d9b7e70b2a5f0d3b9f604ea8 Mon Sep 17 00:00:00 2001 From: katros Date: Mon, 30 Jul 2018 16:05:27 +0200 Subject: [PATCH 2/2] Done through most of 10 --- starter-code/basic-algorithms.js | 38 ++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/starter-code/basic-algorithms.js b/starter-code/basic-algorithms.js index 2fc0d2727..0f68a059a 100644 --- a/starter-code/basic-algorithms.js +++ b/starter-code/basic-algorithms.js @@ -30,10 +30,44 @@ for (var i = hacker2.length - 1; i >= 0; i--){ console.log(navigatorsName); -if (hacker1[0] > hacker2[0]){ +if (hacker1 > hacker2){ console.log("The driver's name goes first"); -} else if (hacker1[0] < hacker2[0]){ +} else if (hacker1 < hacker2){ console.log("Yo, the navigator goes firs definitely") } else { console.log("What?! You both got the same name?"); } + +var newStr = "race car"; +var secondStr = ""; +var firstStr = ""; + +for (var i = newStr.length - 1; i >= 0; i--){ + if (newStr[i] === " " || newStr[i] === ","){ + continue; + } else { + secondStr += newStr[i]; + } +} + +for (var i = 0; i < newStr.length; i++){ + if (newStr[i] === " " || newStr[i] === ","){ + continue; + } else { + firstStr += newStr[i]; + } +} + +console.log(secondStr); +console.log(firstStr); + +if (firstStr === secondStr){ + console.log ("It is a palindrome!"); +} else { + console.log ("It is not a palindrome!"); +} + + +var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque volutpat urna vitae egestas. Suspendisse blandit egestas felis mollis scelerisque. Nam non mattis turpis, vel accumsan nunc. Proin at sodales erat. Quisque vulputate orci sit amet ante bibendum rutrum. Maecenas eleifend commodo maximus. Donec velit mi, volutpat in lacus ac, sagittis imperdiet risus. Praesent varius posuere quam, eget aliquam est condimentum ac. /n Vivamus lacinia nunc sapien, sed auctor massa egestas quis. Phasellus ut turpis eget tortor faucibus consequat. Aenean consequat vitae arcu vitae sodales. Nam dui sapien, laoreet a porttitor sit amet, mattis a nibh. Nam et sollicitudin felis. Nam ornare dignissim metus, a porta est mollis in. Donec libero mauris, consectetur quis eros aliquet, mollis venenatis dui. Morbi ut egestas neque. Etiam ornare finibus porta. /n Sed varius purus orci, sed euismod elit imperdiet vel. Vivamus consequat ante non turpis molestie, et interdum dui iaculis. Nunc eu feugiat justo. Nullam convallis quam ut nulla vehicula dictum. Etiam gravida odio in elit condimentum ultricies. Suspendisse lacinia fringilla dolor. Vivamus rutrum nibh nec mollis euismod. Morbi vulputate nunc ac lacus pharetra, eget pellentesque ipsum tristique. Sed commodo mattis ex, eu imperdiet massa semper in. Cras gravida, massa at accumsan consectetur, erat mauris dictum sapien, ut vehicula dolor nisl ornare mi. Suspendisse potenti." + +console.log(lorem.split(' ').length); \ No newline at end of file