From f84b1d8a0c045117378289fc9779ca51a83bf6f1 Mon Sep 17 00:00:00 2001 From: punam-shelke Date: Wed, 3 Jun 2020 14:41:51 +0530 Subject: [PATCH 1/3] FSJ0520A101 --- app.js | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++-- index.html | 12 ++++++ 2 files changed, 115 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index ab3ad10..a751f02 100644 --- a/app.js +++ b/app.js @@ -2,48 +2,148 @@ // Progression 1: Names and Input // 1.1 Create a variable `ProGrad-1` with the driver's name. +let ProGrad_1 = 'Rohit'; // 1.2 Print `"The driver's name is XXXX"`. +document.write(`The driver's name is ${ProGrad_1}
`); // 1.3 Create a variable `ProGrad-2` with the navigator's name. +let ProGrad_2 = 'Punam'; // 1.4 Print `"The navigator's name is YYYY"`. +document.write(`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 length1 = ProGrad_1.length, + length2 = ProGrad_2.length; +if(length1>length2){ + document.write(`The driver has the longest name, it has ${length1} characters.
`); +} +else if(length1`); +} +else{ + document.write(`Wow, you both have equally long names, ${length1} 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. +//searches for vowels and returns array of their indices +function checkVowels(string){ + let index=[]; + for(let i=0;i`); +} +display(checkVowels(ProGrad_1),ProGrad_1); +display(checkVowels(ProGrad_2),ProGrad_2); // 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 - +function caseCheck(name){ + let upperCaseCount=0, + lowerCaseCount=0; + for(let i=0;i`); +} +caseCheck(ProGrad_1); +caseCheck(ProGrad_2); // 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" +let capital = ProGrad_1.toUpperCase() +for(let i=0;i`); // 3.2 Print all the characters of the navigator's name, in reverse order. i.e. "darGorP" - +for(let i=length2-1;i>-1;i--){ + document.write(ProGrad_2[i]); +} +document.write(`
`); // 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" +let merged =`${ProGrad_1} ${ProGrad_2}`; +document.write(merged + `
`); + +merged = `${merged.substr(length1+1,length2)} ${merged.substr(0,length1)}`; +document.write(merged+`
`); // 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? +if(ProGrad_1`); +} +else if(ProGrad_1>ProGrad_2){ + document.write(`Yo, the navigator goes first definitely.
`); +} +else{ + document.write(`What?! You both have the same name?
`); +} // Bonus Time! // Bonus 1: // Go to lorem ipsum generator and: // Generate 3 paragraphs. Store the text in a variable type of string. +let text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis, atque facilis? Cupiditate nesciunt fugiat distinctio laborum fugit quisquam minima ratione, tempore necessitatibus magni omnis, quia quam provident, neque consequatur quod? Iste nostrum ipsa quae, recusandae nulla iusto dolor amet hic. Autem earum dolores sequi ipsum accusantium ipsam repellendus, ab cumque inventore optio fugiat minus corporis ut explicabo repellat? Porro, necessitatibus."; +let count = 0; // Make your program count the number of words in the string. +for(let i=0;i + + + + + Document + + + + + + \ No newline at end of file From 3bb4ee8652fbc5c3364721e375d152c30f16707b Mon Sep 17 00:00:00 2001 From: punam-shelke Date: Wed, 3 Jun 2020 14:44:08 +0530 Subject: [PATCH 2/3] FSJ0520A101 --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index a751f02..fddea8b 100644 --- a/app.js +++ b/app.js @@ -137,7 +137,7 @@ for(let i=0;i Date: Wed, 3 Jun 2020 23:44:15 +0530 Subject: [PATCH 3/3] FSJ0520A101 --- .vscode/settings.json | 3 +++ app.js | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/app.js b/app.js index fddea8b..c2c61e4 100644 --- a/app.js +++ b/app.js @@ -144,6 +144,23 @@ document.write(`Words in string ${count}`); // 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: let phraseToCheck = "A man, a plan, a canal, Panama!"; +let reversed = `` ,original = ``; +//first convert to lower/upper case +original = phraseToCheck; +phraseToCheck = phraseToCheck.toLowerCase(); +//remove spaces using regular expressions +phraseToCheck = phraseToCheck.replace(/ /g, ""); +//debugging console.log(`${phraseToCheck}`); +phraseToCheck = phraseToCheck.replace(/\'|\,|\!|\?|\"/g, ""); +//debugging console.log(`${phraseToCheck}`); + +for(let i= phraseToCheck.length - 1 ; i > -1 ; i-- ){ + reversed += phraseToCheck[i]; +} +//debugging console.log(`${reversed}`); +if(phraseToCheck == reversed){ + document.write(`
${original} is a palindrome`); +} // "A man, a plan, a canal, Panama!" // "Amor, Roma" // "race car"