When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!
If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer!
I am very confused by an issue which arises in the bellow code which is intended to randomly seed a board for minesweeper with bombs. Please focus in particular on the lines in between the multi-line comments. While I want for the board to be filled with some bombs, the bellow code fills the entire board with bombs.
Please note that were is written ‘\x’, treat it as ‘x’.
//Checks if input is a valid integer
let yarr=new Array(size).fill(" “);
/ Randomly Places A Number of bombs equal to the
value of ‘size’ around the board /
/ Prints out a 2x2 Array where each Element of Each
array is ‘B’ as opposed to only some of them
being ‘B’ and the remaining being ’ ’ /
I am especially confused given how the bellow code works as I would intend:
arr.push(new Array(10).fill(" “));
I would be very grateful for any advice, thank you in advance.