Hello everyone, I’m currently at the Pig Latin challenge and I manage to pass every test except the “no vowels” one. After taking a look at the code provided by FCC, I came across one line I’m having trouble understanding!
// Find how many consonants before the first vowel.
var vowelIndice = str.indexOf(str.match(regex)[0]);
Could someone explain to me exactly what this line does and especially that “[0]” at the end.
Thanks in advance;
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin/
Link to the basic solution provided by FCC:
http://forum.freecodecamp.org/t/freecodecamp-algorithm-challenge-guide-pig-latin/16039