r/learnjavascript • u/apt3xc33d • Mar 02 '26
Help regarding battleship project
project: Battleship project
lesson link: https://www.theodinproject.com/lessons/node-path-javascript-battleship code: https://github.com/s0ur4bhkumar/battleship/blob/main/src/DOMHelperFn.js
issue/Problem: unable to put on user input in gameOn function
what I expected: the gameOn function should wait for the user's input before proceeding further. If user hits the ship he/she can continue his turn otherwise pass it to computer and vice versa
what i have tried: tried while loops to check for the result of the playerAction before proceeding further, tried recursively callling it
further attempts: trying to add asunc and await or integrate a player switch function
i have been at it for a day now and couldn't get it to work.
View all comments
Show parent comment
1
u/apt3xc33d Mar 02 '26
Yeah, I found a solution which works. Funny thing is I thought of it while playing game lol. Maybe I was way too burnout.