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 ab3ad10..c2c61e4 100644 --- a/app.js +++ b/app.js @@ -2,48 +2,165 @@ // 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 -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" diff --git a/index.html b/index.html index e69de29..88f2010 100644 --- a/index.html +++ b/index.html @@ -0,0 +1,12 @@ + + + + + + Document + + + + + + \ No newline at end of file