Skip to content
Advertisement

Why is my random number generator becoming an unused assignment when using it to input values for 2d array?

I have been making a basic game of battleship and to get the CPU to choose ship locations on a 2d array I am making two random number generators to pick values from 1 to 8 on a separate method. For some reason, the random generators show up as unused and I don’t know why. so far this is what I have. If anyone knows what I’m doing wrong please let me know.

JavaScript
JavaScript

Advertisement

Answer

Here should be a complete code

JavaScript

or use break instead of the valid boolean

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement