Challenge 19 - Stuck


#1

I’m not sure if I am missing something else, or if it’s the lack of decimal places that is killing me.

I have provided the array [9,3] as well as [“9.00”,“3.00”], but neither worked. I also don’t seem to be able to praseFloat() in order to force the integer to have decimal places.

Here is my unsuccessful attempt, which returns an array with 2 strings:

function percentageReport(){
const grid_size = GRID.length * GRID[0].length;
var report = [];
// var rocks = allRocks().length / grid_size * 100;
// var ships = allShips().length / grid_size * 100
// report.push(rocks.toFixed(2));
// report.push(ships.toFixed(2));
report.push(
parseFloat((allRocks().length / grid_size * 100)).toFixed(2)
);
report.push(
parseFloat((allShips().length / grid_size * 100)).toFixed(2)
);
return report;
}


#2

If you look at the original grid, I count 9 rocks (9.00%), 7 currents (7.00%) and 3 ships (3.00%). If you check out the challenge again it is looking for an array to be returned as [ rocks%, currents%]. (without the % symbols!)

Hope this helps!


#3

Oh god, I was looking for ships instead of currents… I kept getting [9 ,3] and I didn’t even notice I was supposed to be getting [9. 7]

Thank you.