Answer to Question #329204 in HTML/JavaScript Web Application for hari

Question #329204

the goal of this coding exam is to quickly get you off the ground with the array method filter(). given vowels List in the prefilled code and ward List as an input, write a js program to, filter the words from wordsList with at least one vowel in it. log the array containing the filtered words in the console


"use strict";

process.stdin.resume();

process.stdin.setEncoding("utf-8");

let inputString = "";

let currentLine = 0;

process.stdin.on("data", (inputStdin) => {

 inputString += inputStdin;

});

process.stdin.on("end", (_) => {

 inputString = inputString.trim().split("\n").map((str) => str.trim());

 main();

});

function readLine() {

 return inputString[currentLine++];

}

function main() {

 const wordsList = JSON.parse(readLine().replace(/'/g, '"'));

 const vowelsList = ["a", "e", "i", "o", "u"]

 // Write your code here

}


1
Expert's answer
2022-04-15T16:34:20-0400
"use strict";


process.stdin.resume();


process.stdin.setEncoding("utf-8");


let inputString = "";


let currentLine = 0;


process.stdin.on("data", (inputStdin) => {


 inputString += inputStdin;


});


process.stdin.on("end", (_) => {


 inputString = inputString.trim().split("\n").map((str) => str.trim());


 main();


});


function readLine() {


 return inputString[currentLine++];


}


function main() {


 const wordsList = JSON.parse(readLine().replace(/'/g, '"'));


 const vowelsList = ["a", "e", "i", "o", "u"]


let check
for(let i = 0; i < wordsList.length; i++){
  for(let j = 0; j < vowelsList.length; j++){
    check = wordsList[i].includes(vowelsList[j]);
      if(x)
      break;
}
  if(!check)
    wordsList.splice(i, 1);
}


console.log(wordsList);


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS