Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to count characters

const str = 'abracadabra'

function getCountCodewars(str) {
  console.log(str.match(/[aeiou]/ig)) // => [ 'a', 'a', 'a', 'a', 'a' ]

  return (str.match(/[aeiou]/ig) || []).length // => 5
}



console.log(getCountCodewars(str)) // => 5
 
PREVIOUS NEXT
Tagged: #count #characters
ADD COMMENT
Topic
Name
3+9 =