I just fixed those problems and your code worked for me. Again, I think this is a messy way to do it (you also don’t need that else) but it can work.
this is it in total. items is an array and my code has too return all the even elements in that array
function findEvenLengthStrings(items) {
// Your code goes here...
var newArray = [ ];
for (var i = 0; i < findEvenLengthStrings.length; i++) {
if (findEvenLengthStrings[i].length % 2 === 0){
newArray.push(findEvenLengthStrings[i]);
}
}
return newArray;
}
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
function findEvenLengthStrings(items) {
// Your code goes here...
var newArray = [ ]; // var is a legacy feature - const is better
for (var /* use let here */ i = 0; i < findEvenLengthStrings.length; i++) {
if (findEvenLengthStrings[i].length % 2 === 0) { // why are you trying to index into the function?
newArray.push(findEvenLengthStrings[i]); // this isn't the name of the array of strings
}
}
return newArray;
}