Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

218
Views
obtenga el número, luego obtenga n nombres y cuente cada palabra vocal char JS

El objetivo es obtener un número n del usuario, luego obtener n palabras del usuario y mostrar el recuento de caracteres de vocales de cada palabra en la consola. Pero no obtiene los conteos correctos. #JS #vocal

 let n = prompt('Enter the number:'); let wordList = []; let vowelCounter = []; let stringWordList = ''; for (i = 0; i < n; i++) { wordList.push(prompt((i + 1) + 'Word #')) } debugger function getVowels(str) { var m = str.toString().match(/[aeiou]/gi); return m === null ? 0 : m.length; }; /*function vowelCount(str) { return str.toString().replace(/[^aeiou]/gi, "").length;*/ }; for (i = 0; i < n; i++) { stringWordList = wordList[i].toString vowelCounter.push(getVowels(stringWordList)); console.log(wordList[i] + ':' + vowelCounter[i]); }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

elimine el símbolo de zanahoria de la expresión regular e intente:

 function getVowels(str) { var m = str.toString().match(/[aeiou]/gi); return m === null ? 0 : m.length; }; console.log(getVowels("testme123"));

about 4 years ago · Juan Pablo Isaza Report

0

Después de eliminar su símbolo de zanahoria, debe limpiar un poco su código (no se estaba ejecutando en JSFIDDLE):

 let n = prompt('Enter the number:'); let wordList = []; let vowelCounter = []; let stringWordList = ''; for (i = 0; i < n; i++) { wordList.push(prompt((i + 1) + 'Word #')) } //debugger function getVowels(myString) { var m = myString.match(/[aeiou]/gi); return m === null ? 0 : m.length; } /*function vowelCount(str) { return str.toString().replace(/[^aeiou]/gi, "").length;*/ for (i = 0; i < n; i++) { stringWordList = wordList[i].toString(); vowelCounter.push(getVowels(stringWordList)); console.log(wordList[i] + ':' + vowelCounter[i]); }

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!