FCC doesnt recognize my answer to Pig Latin challenge

Tell us what’s happening:
I am working on this challenge using Repl.it as a compiler. According to the tests i’ve made, my function is returning all the expected outputs. However, FCC doesnt recognise my code as valid, because it fails the tests where the word starts in a consonant.

Can you please help me identify where am I going wrong?

Your code so far

function translatePigLatin(str) {
let vowel = ['a','e','i','o','u'];
let strArr = str.split('');
let firstVowelIndex = strArr.findIndex(ele => {return vowel.includes(ele)})

if (vowel.includes(strArr[0]) == true) {
str = strArr.join('');
} else if (vowel.includes(strArr[0]) == false && firstVowelIndex !== -1){
let firstCons = [];
for (let i = 0; i < firstVowelIndex; i++){
slicedArr = strArr.slice(firstVowelIndex);
finalArr = slicedArr.concat(firstCons)
str = finalArr.join('') + 'ay';
} else {return str + 'ay'}
return str;

Also, if you could evaluate my code and point out the improvements I can make i would really apreciate any criticisms.

Thank you very much,

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36.

Challenge: Pig Latin

Link to the challenge:


Your code is almost OK, You just have two non declared variables, which are actually shown on the FCC console:

ReferenceError: assignment to undeclared variable slicedArr

After fixing that, You still have another error, but I’ll let You try to find it :slight_smile:.

1 Like

Where do you see the console on FCC? After I run the code i can only see the following:

// running tests


should return “aliforniacay”.


should return “aragraphspay”.


should return “oveglay”. Should handle words where the first vowel comes in the middle of the word.


should return “artzschway”. // tests completed

EDIT: I fixed the two missing non declared values and the code run perfectly :smiley: But I still don’t know how to check FCC consle.

EDIT2: My code ran correctly in Repl.it because i forgot to add ‘use strict’ to the top, so it declared the variables for me

1 Like

Hmm, well, it depends on the size of Your screen, but it should be on the bottom right of the screen, where the results are displayed.

Initially, and without errors, it says:

* Your test output will go here.

1 Like