From 54f7beb4c5780c2c2626c1c4c8c215f2b21d8cf5 Mon Sep 17 00:00:00 2001 From: Varsha Date: Tue, 28 Apr 2020 13:47:36 +0530 Subject: [PATCH 1/3] first commit --- app.js | 16 ++++++++++++++-- index.html | 29 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index ab3ad10..63daaca 100644 --- a/app.js +++ b/app.js @@ -11,7 +11,19 @@ // - The driver has the longest name, it has XX characters. or // - It seems that the navigator has the longest name, it has XX characters. or // - Wow, you both have equally long names, XX characters!. - +let ProGrad_1 = " Pavan Ganesh"; +console.log("The Driver's name is " + ProGrad_1); +let ProGrad_2 = " Varsha Bisht"; +console.log("The navigator's name is " + ProGrad_2); +let driver = ProGrad_1.length; +navigator = ProGrad_2.length; +if (driver > navigator) { + console.log(" The driver has the longest name, it has " + driver + " characters."); +} else if (driver < navigator) { + console.log("It seems that the navigator has the longest name, it has " + navigator + " characters"); +} else { + console.log("Wow, you both have equally long names, " + driver + " characters!."); +} // 2.2. Check if the string contains vowels or not. // - If it contains vowels, print the name, and also print the vowel letters along with the vowel index. or // - print no vowels @@ -53,4 +65,4 @@ // "put it up" // "Was it a car or a cat I saw?" and "No 'x' in Nixon". -// Hint: If you use Google to help you to find solution to this iteration, you might run into some solutions that use advanced string or array methods (such as join(), reverse(), etc.). However, try to apply the knowledge you currently have since you can build pretty nice solution with just using for loop, if-else statements with some break and continue... Just sayin' +// Hint: If you use Google to help you to find solution to this iteration, you might run into some solutions that use advanced string or array methods (such as join(), reverse(), etc.). However, try to apply the knowledge you currently have since you can build pretty nice solution with just using for loop, if-else statements with some break and continue... Just sayin' \ No newline at end of file diff --git a/index.html b/index.html index e69de29..be6b804 100644 --- a/index.html +++ b/index.html @@ -0,0 +1,29 @@ + + + + + + + Document + + + + + + + + \ No newline at end of file From 96d5ee4e27bda261f50c3311ada4d1164f202ada Mon Sep 17 00:00:00 2001 From: Varsha Date: Tue, 28 Apr 2020 16:30:44 +0530 Subject: [PATCH 2/3] first commit --- app.js | 43 +++++++++++++++++++++++++++++++++++++++++-- index.html | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 63daaca..6ae35ff 100644 --- a/app.js +++ b/app.js @@ -24,11 +24,35 @@ if (driver > navigator) { } else { console.log("Wow, you both have equally long names, " + driver + " characters!."); } + + + +let count = 0; +let vowel = "aeiou"; +for (let x = 0; x < ProGrad_2.length; x++) { + if (vowel.indexOf(ProGrad_2[x]) !== -1) { + count++; + } +} +console.log(ProGrad_2 + " no. of vowels " + count); // 2.2. Check if the string contains vowels or not. // - If it contains vowels, print the name, and also print the vowel letters along with the vowel index. or // - print no vowels // - for example. In String ProGrad - o and a are vowels. Print ProGrad o a 2 5. +let upper = 0; +let lower = 0; +for (var i = 0; i < ProGrad_2.length; i++) { + if (/[A-Z]/.test(ProGrad_2.charAt(i))) { + upper++; + } else { + lower++; + } +} +console.log("no of lower case " + lower);; +console.log("no of upper case " + upper); +let str = ProGrad_1.split(""); +console.log("after removing space" + str); // 2.3. Check if the string contains uppercase and lowercase characters Xx // - Print the number of upper case characters // - Print the number of lower case characters @@ -38,14 +62,29 @@ if (driver > navigator) { // 3.1 Print all the characters of the driver's name, separated by a space and in capitals i.e. "ProGrad" // 3.2 Print all the characters of the navigator's name, in reverse order. i.e. "darGorP" - +var newString = ""; +for (var i = ProGrad_2.length - 1; i >= 0; i--) { + newString += str[i]; +} +document.write(newString); // 3.3 Merge both the characters such that driver is followed by Navigator like "ProGrad FACEPrep" // - Now bring the FACEPrep to the start and send ProGrad to the back like "FACEPrep ProGrad" - +var mergeString = ProGrad_1.concat(ProGrad_2); +document.write(mergeString); // 3.3 Depending on the lexicographic order of the strings, print: // - The driver's name goes first. // - Yo, the navigator goes first definitely. // - What?! You both have the same name? +var mergeString1 = ProGrad_2.concat(ProGrad_1); +document.write(mergeString1 + "\n "); + + +if (ProGrad_1.localeCompare(ProGrad_2) == -1) + document.write("driver name goes first"); +else if (ProGrad_1.localeCompare(ProGrad_2) == 1) + document.write("navigator should come first") +else + document.write("both have same name"); // Bonus Time! // Bonus 1: diff --git a/index.html b/index.html index be6b804..1d43577 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,54 @@ } else { console.log("Wow, you both have equally long names, " + driver + " characters!."); } + + let count = 0; + let vowel = "aeiou"; + for (let x = 0; x < ProGrad_2.length; x++) { + if (vowel.indexOf(ProGrad_2[x]) !== -1) { + count++; + } + } + console.log(ProGrad_2 + " no. of vowels " + count); + + let upper = 0; + let lower = 0; + for (var i = 0; i < ProGrad_2.length; i++) { + if (/[A-Z]/.test(ProGrad_2.charAt(i))) { + upper++; + } else { + lower++; + } + } + console.log("no of lower case " + lower);; + console.log("no of upper case " + upper); + + let str = ProGrad_1.split(""); + console.log("after removing space" + str); + + + var newString = ""; + for (var i = ProGrad_2.length - 1; i >= 0; i--) { + newString += str[i]; + } + document.write(newString); + + + var mergeString = ProGrad_1.concat(ProGrad_2); + document.write(mergeString + "\n "); + + var mergeString1 = ProGrad_2.concat(ProGrad_1); + document.write(mergeString1 + "\n "); + + if (ProGrad_1.localeCompare(ProGrad_2) == -1) + document.write("driver name goes first"); + else if (ProGrad_1.localeCompare(ProGrad_2) == 1) + document.write("navigator should come first") + else + document.write("both have same name"); + + From 7e4ff13e711fea3056c783c9a69743722c346c45 Mon Sep 17 00:00:00 2001 From: Varsha Date: Thu, 30 Apr 2020 12:26:10 +0530 Subject: [PATCH 3/3] first commit --- app.js | 87 +++++++++++++++++++++++++++--------------------------- index.html | 83 ++++++--------------------------------------------- 2 files changed, 53 insertions(+), 117 deletions(-) diff --git a/app.js b/app.js index 6ae35ff..2397746 100644 --- a/app.js +++ b/app.js @@ -1,62 +1,65 @@ // Important Note - No Built-in functions to be used -// Progression 1: Names and Input +// Progression 1: Names and Input // 1.1 Create a variable `ProGrad-1` with the driver's name. // 1.2 Print `"The driver's name is XXXX"`. // 1.3 Create a variable `ProGrad-2` with the navigator's name. // 1.4 Print `"The navigator's name is YYYY"`. +let ProGrad_1 = " Pavan Ganesh"; +console.log("The Driver's name is " + ProGrad_1); + +let ProGrad_2 = " Varsha Bisht"; +console.log("The navigator's name is " + ProGrad_2); // Progression 2: Control Statements - 1 // 2.1. Depending on which name is longer, print: // - The driver has the longest name, it has XX characters. or // - It seems that the navigator has the longest name, it has XX characters. or // - Wow, you both have equally long names, XX characters!. -let ProGrad_1 = " Pavan Ganesh"; -console.log("The Driver's name is " + ProGrad_1); -let ProGrad_2 = " Varsha Bisht"; -console.log("The navigator's name is " + ProGrad_2); let driver = ProGrad_1.length; -navigator = ProGrad_2.length; +let navigator = ProGrad_2.length; if (driver > navigator) { - console.log(" The driver has the longest name, it has " + driver + " characters."); + console.log( + " The driver has the longest name, it has " + driver + " characters." + ); } else if (driver < navigator) { - console.log("It seems that the navigator has the longest name, it has " + navigator + " characters"); + console.log( + "It seems that the navigator has the longest name, it has " + + navigator + + " characters" + ); } else { - console.log("Wow, you both have equally long names, " + driver + " characters!."); + console.log( + "Wow, you both have equally long names, " + driver + " characters!." + ); } - +// 2.2. Check if the string contains vowels or not. +// - If it contains vowels, print the name, and also print the vowel letters along with the vowel index. or +// - print no vowels +// - for example. In String ProGrad - o and a are vowels. Print ProGrad o a 2 5. let count = 0; let vowel = "aeiou"; for (let x = 0; x < ProGrad_2.length; x++) { - if (vowel.indexOf(ProGrad_2[x]) !== -1) { - count++; - } + if (vowel.indexOf(ProGrad_2[x]) !== -1) { + count++; + } } console.log(ProGrad_2 + " no. of vowels " + count); -// 2.2. Check if the string contains vowels or not. -// - If it contains vowels, print the name, and also print the vowel letters along with the vowel index. or -// - print no vowels -// - for example. In String ProGrad - o and a are vowels. Print ProGrad o a 2 5. -let upper = 0; -let lower = 0; -for (var i = 0; i < ProGrad_2.length; i++) { - if (/[A-Z]/.test(ProGrad_2.charAt(i))) { - upper++; - } else { - lower++; - } -} -console.log("no of lower case " + lower);; -console.log("no of upper case " + upper); -let str = ProGrad_1.split(""); -console.log("after removing space" + str); // 2.3. Check if the string contains uppercase and lowercase characters Xx // - Print the number of upper case characters // - Print the number of lower case characters - +let ProGrad = "VasHa"; +var uppercase = 0; +var lowercase = 0; +for (var len = 0; len < ProGrad.length; len++) { + if (ProGrad[len] >= "a" && ProGrad[len] <= "z") lowercase++; + else uppercase++; +} +console.log("uppercase in " + ProGrad + " " + uppercase); +console.log("lowercase in " + ProGrad + " " + lowercase); // Progression 3: Control Statements - 2 // 3.1 Print all the characters of the driver's name, separated by a space and in capitals i.e. "ProGrad" @@ -64,27 +67,25 @@ console.log("after removing space" + str); // 3.2 Print all the characters of the navigator's name, in reverse order. i.e. "darGorP" var newString = ""; for (var i = ProGrad_2.length - 1; i >= 0; i--) { - newString += str[i]; + newString += ProGrad_2[i]; } -document.write(newString); +console.log(newString); // 3.3 Merge both the characters such that driver is followed by Navigator like "ProGrad FACEPrep" // - Now bring the FACEPrep to the start and send ProGrad to the back like "FACEPrep ProGrad" -var mergeString = ProGrad_1.concat(ProGrad_2); -document.write(mergeString); // 3.3 Depending on the lexicographic order of the strings, print: // - The driver's name goes first. // - Yo, the navigator goes first definitely. // - What?! You both have the same name? -var mergeString1 = ProGrad_2.concat(ProGrad_1); -document.write(mergeString1 + "\n "); - +driver = "ProGrad"; +navigator = "FACEPrep"; +console.log(driver + navigator); +console.log(navigator + " " + driver); if (ProGrad_1.localeCompare(ProGrad_2) == -1) - document.write("driver name goes first"); + console.log("driver name goes first"); else if (ProGrad_1.localeCompare(ProGrad_2) == 1) - document.write("navigator should come first") -else - document.write("both have same name"); + console.log("navigator should come first"); +else console.log("both have same name"); // Bonus Time! // Bonus 1: @@ -104,4 +105,4 @@ else // "put it up" // "Was it a car or a cat I saw?" and "No 'x' in Nixon". -// Hint: If you use Google to help you to find solution to this iteration, you might run into some solutions that use advanced string or array methods (such as join(), reverse(), etc.). However, try to apply the knowledge you currently have since you can build pretty nice solution with just using for loop, if-else statements with some break and continue... Just sayin' \ No newline at end of file +// Hint: If you use Google to help you to find solution to this iteration, you might run into some solutions that use advanced string or array methods (such as join(), reverse(), etc.). However, try to apply the knowledge you currently have since you can build pretty nice solution with just using for loop, if-else statements with some break and continue... Just sayin' diff --git a/index.html b/index.html index 1d43577..eb4204e 100644 --- a/index.html +++ b/index.html @@ -1,76 +1,11 @@ - - - - - Document - - - - - - - - - - \ No newline at end of file + + + + Loopy loobs + + + + +