Theres nothing wrong with my 13! HOW DOESNT IT WORK


#1

function allRocks(){
let letters = [‘A’,‘B’,‘C’,‘D’,‘E’,‘F’,‘G’,‘H’,‘I’,‘J’,‘K’,‘L’,‘M’,‘N’,‘O’,‘P’,‘Q’,‘R’,‘S’,‘T’,‘U’,‘V’,‘W’,‘X’,‘Y’,‘Z’];
let new_list = [];
for (var i =0; i < countRows(); i++ ){
for (var j = 0; j < countColumns(); j++){
var coordinate = letters[j] + String(i + 1);
if (isRock(coordinate)){
new_list.push(coordinate);
}
}
}
return new_list;
}
function allCurrents(){
let letters = [‘A’,‘B’,‘C’,‘D’,‘E’,‘F’,‘G’,‘H’,‘I’,‘J’,‘K’,‘L’,‘M’,‘N’,‘O’,‘P’,‘Q’,‘R’,‘S’,‘T’,‘U’,‘V’,‘W’,‘X’,‘Y’,‘Z’];
let new_list = [];
for (var i = 0; i < countRows(); i+= 1 ){
for (var j = 0; j < countColumns(); j+= 1){
var coordinate = letters[j] + String(i+1);
if (isCurrent(coordinate)){
new_list.push(coordinate);
}
}
}
return new_list;
}


#2

I copied your code to codepen, and the first error I received was the type of quotes used for letters.
When you swap them for different quotes, does it work? There are some functions that are missing for me to fully run your code. (isCurrent and isRock)

In addition you’re using i+=1 and j+=1 for your allCurrents() for loops while using i++ and j++ for the allRocks() for loops. Is there a reason why?

In addition I would recommend using let instead of var in your for loops, as ‘let’ is scope specific:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let

Hopefully these changes help give some insight and perhaps correct the errors.