Skip to content
Advertisement

Tag: scope

Reset an array and have it be mutable again

I am making tic-tac-toe from TOP, I’m not looking for someone to do my homework I just think I’m severely misunderstanding arrays, and or scope. I have a module “Game” where I store the game info It is all controlled from a controller module, that sets up the players, plays the round, changes the turn and so on. For the

Function parameter is not defined in callback

I am trying to get the location of the user and using that I am trying to get the city. I don’t why but when I call the query function, the city parameter is having some value but it is not reflected in the callback function’s if condition. However, if I replace the city variable in the If condition with

How can I assign forEach to variable? Its possible?

Hello everyone:) I’m trying to write rock, paper, scissors game but I have a little problem. Is there any option to assign let playerChoice = buttons.forEach… to any variable as I did in this code? Unfortunately, it doesn’t work like this. I attached my code below. Thanks for any tips! Answer You can’t use forEach to do what you want

How does variable setting work with await?

Can someone explain to me why this is not working the way I am expecting? I am expecting the last console.log to run after my functions run, but it is returning empty length string instead of the actual date. These are the variables I want to set after my function call. Declaring them now so the scope is set globally.

Only in Safari: ReferenceError Can’t find variable

Many of my scripts look like this: They work fine on Chrome, Firefox, Edge and Opera but on Safari I get the error: Workaround If I declare the constants before the if statement the code works… …but I don’t understand why and I don’t what to make the constant globally available. Maybe someone can explain to me that Safari-only-behavior. Answer

Advertisement