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
}
"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);
}
Comments
Leave a comment