From 9fe2fa9371502f51a2cc2660e991fc3bbf58750a Mon Sep 17 00:00:00 2001 From: Mahesh Tatyasaheb Chavan Date: Thu, 13 Aug 2020 18:50:57 +0530 Subject: [PATCH 1/2] Onr progression is remains --- app.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- index.html | 10 ++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index ab3ad10..78f2cd7 100644 --- a/app.js +++ b/app.js @@ -6,27 +6,76 @@ // 1.3 Create a variable `ProGrad-2` with the navigator's name. // 1.4 Print `"The navigator's name is YYYY"`. +var mahesh = "ProGrad-1"; +console.log("The driver's name is " + mahesh); +var silentcoder = "ProGrad-2"; +console.log("The navigator's is " + silentcoder); // 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!. +if (mahesh.length == silentcoder.length) { + console.log("Wow, you both have equally long names, " + mahesh.length + " characters!"); +} else if (mahesh.length > silentcoder.length) { + console.log("The driver has the longest name, it has " + silentcoder.length + " characters"); +} else { + console.log("It seems that the navigator has the longest name, it has " + silentcoder.length + " 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. +var string = "ProGrad"; +const vowels = ["a", "e", "i", "o", "u"]; +var v = ""; +var c = ""; +for (let letter of string.toLowerCase()) { + if (vowels.includes(letter)) { + v += letter + " "; + c+=string.indexOf(letter)+" "; + } +} +if (v.length > 0) { + console.log(string + " " + v + " " + c); +} else { + console.log("no vowels"); +} // 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 +var string = "ProGrad Mahesh"; +var upperCounter = 0; +var lowerCounter = 0; +for (let letter of string) { + if (letter == letter.toUpperCase()) { + upperCounter++; + } else if (letter == letter.toLowerCase()) { + lowerCounter++; + } +} + +console.log("Number of Upper case characters = "+upperCounter); +console.log("Number of Lower case characters = "+lowerCounter); // 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" +var result = "" +for (let letter of mahesh){ + result += letter.toUpperCase() + " "; +} +console.log(result); // 3.2 Print all the characters of the navigator's name, in reverse order. i.e. "darGorP" - +var reverse=""; +for (var i = silentcoder.length - 1; i >= 0; i--){ + reverse+=silentcoder[i]+" "; +} +console.log(reverse); // 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" @@ -34,7 +83,11 @@ // - The driver's name goes first. // - Yo, the navigator goes first definitely. // - What?! You both have the same name? - +if (mahesh.localeCompare(silentcoder)){ + console.log("The driver's name goes first."); +}else{ + +} // Bonus Time! // Bonus 1: // Go to lorem ipsum generator and: diff --git a/index.html b/index.html index e69de29..81c544c 100644 --- a/index.html +++ b/index.html @@ -0,0 +1,10 @@ + + + + + Document + + + + + \ No newline at end of file From bbf4021756672cdff406c1d4720071ce50bf75f3 Mon Sep 17 00:00:00 2001 From: Mahesh Tatyasaheb Chavan Date: Sat, 15 Aug 2020 11:19:40 +0530 Subject: [PATCH 2/2] ProGrad ID:1425684 --- app.js | 53 +++++++++++++++++++++++++++++++++++++++-------------- index.html | 12 +++++------- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/app.js b/app.js index 78f2cd7..da21544 100644 --- a/app.js +++ b/app.js @@ -33,10 +33,10 @@ var string = "ProGrad"; const vowels = ["a", "e", "i", "o", "u"]; var v = ""; var c = ""; -for (let letter of string.toLowerCase()) { - if (vowels.includes(letter)) { - v += letter + " "; - c+=string.indexOf(letter)+" "; +for (let i = 0; i < string.length; i++) { + if (string[i] === 'a' || string[i] === 'e' || string[i] === 'i' || string[i] === 'o' || string[i] === 'u') { + v += string[i] + " "; + c += i + " "; } } if (v.length > 0) { @@ -59,21 +59,21 @@ for (let letter of string) { } } -console.log("Number of Upper case characters = "+upperCounter); -console.log("Number of Lower case characters = "+lowerCounter); +console.log("Number of Upper case characters = " + upperCounter); +console.log("Number of Lower case characters = " + lowerCounter); // 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" var result = "" -for (let letter of mahesh){ +for (let letter of mahesh) { result += letter.toUpperCase() + " "; } console.log(result); // 3.2 Print all the characters of the navigator's name, in reverse order. i.e. "darGorP" -var reverse=""; -for (var i = silentcoder.length - 1; i >= 0; i--){ - reverse+=silentcoder[i]+" "; +var reverse = ""; +for (var i = silentcoder.length - 1; i >= 0; i--) { + reverse += silentcoder[i] + " "; } console.log(reverse); // 3.3 Merge both the characters such that driver is followed by Navigator like "ProGrad FACEPrep" @@ -83,10 +83,12 @@ console.log(reverse); // - The driver's name goes first. // - Yo, the navigator goes first definitely. // - What?! You both have the same name? -if (mahesh.localeCompare(silentcoder)){ +if (mahesh.localeCompare(silentcoder)) { console.log("The driver's name goes first."); -}else{ - +} else if (silentcoder.localeCompare(mahesh)) { + console.log("Yo, the navigator goes first definitely."); +} else { + console.log("What ? !You both have the same name ? "); } // Bonus Time! // Bonus 1: @@ -94,7 +96,18 @@ if (mahesh.localeCompare(silentcoder)){ // Generate 3 paragraphs. Store the text in a variable type of string. // Make your program count the number of words in the string. // Make your program count the number of times the Latin word et appears. + +var string = "Lorem ipsum, dolor sit amet consectetur adipisicing elit.Culpa, neque earum fugiat a sapiente laborum dicta id libero dignissimos eos commodi voluptate ullam, soluta suscipit velit accusantium voluptatum nemo voluptates Lorem ipsum dolor sit amet consectetur, adipisicing elit.Autem error temporibus ducimus dolor consectetur voluptates reprehenderit dicta facere sint tempore, laboriosam repudiandae necessitatibus asperiores maxime.Consequuntur iste dolorum reiciendis fuga Lorem ipsum dolor sit amet consectetur adipisicing elit.Rerum, perspiciatis delectus!Tempore dignissimos corporis tenetur aut necessitatibus.Laborum, quaerat.Est, similique dolorem cupiditate culpa quas vitae hic blanditiis praesentium odit!" +var total = 0; +for (let i = 0; i < string.length; i++) { + if (string[i] === " ") { + total += 1; + } +} +total += 1; +console.log(total); // Bonus 2: + // Create a new variable phraseToCheck and have it contain some string value. Write a code that will check if the value we assigned to this variable is a Palindrome. Here are some examples of palindromes: // "A man, a plan, a canal, Panama!" @@ -106,4 +119,16 @@ if (mahesh.localeCompare(silentcoder)){ // "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' +var phraseToCheck = "mom"; +var result = ""; +for (let i = phraseToCheck.length - 1; i >= 0; i--) { + result += phraseToCheck.charAt(i); +} +if (result === phraseToCheck) { + console.log("input string is palindrome"); +} else { + console.log("input string is not palindrome"); +} + + +// 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 81c544c..13b2397 100644 --- a/index.html +++ b/index.html @@ -1,10 +1,8 @@ - - + + Document - - - - - \ No newline at end of file + + +