Closed bmaiden closed 9 months ago
What does your colors index look like?
const colors = [ "red", "blue", "green", "yellow", "orange", "purple", "pink", "darkgray", "red", "blue", "green", "yellow", "orange", "purple", "pink", "darkgray", ];
Where are you using the squareColor variable to apply the color?
Want to use it in the the squarePicked function.
Sorry when the square is picked.
I should have stated more clearly, share the function where that's happening. Sorry about the miscommunication!
I want to use the squareColor within this function.
//function -squarePicked- determines squares selected with a event listener
function squarePicked(event) {
//get index of square when clicked on
const squareIdx = parseInt(event.target.id.replace(`sq-`, ""));
// console.log('squareIdx:', squareIdx) //console displays squareIdx
//changed board array null to numbers and colors display on board.
//change color of square when clicked on
//render updated state
render();
}
I am struggling here, been working on this aspect for 1 1/2 days now.
I am not sure how to proceed with the coding I have. Help.
Thank you, Nabila!! You went above and beyond, it's very much appreciated. Your approach on walking me through my coding challenge and explain in detail what changes were needed and why, makes me feel better prepared to finish this project. Thank you again!
What's the problem you're trying to solve?
Assigning randomized color choices to variable, squareColor
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
returning only one color versus an array of colors
What is your best guess as to the source of the problem?
?
What things have you already tried to solve the problem?
moving "squareColor = colors[randomIndex];" under splice statement.
Paste a link to your repository here
https://github.com/bmaiden/memory-browser-game/commits/main