MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/z8z4jh/help/iyiibi4/?context=3
r/learnjavascript • u/Lelouch_5 • Nov 30 '22
Can someone plz tell me , why I am getting errors?
131 comments sorted by
View all comments
15
const rps = (p1, p2) => { const RESULT_MAP = { 'scissors': { 'paper': 'Player 1 won!', 'rock': 'Player 2 won!', 'scissors': 'Draw!', }, 'rock': { 'scissors': 'Player 1 won!', 'paper': 'Player 2 won!', 'rock': 'Draw!', }, 'paper': { 'scissors': 'Player 2 won!', 'rock': 'Player 1 won!', 'paper': 'Draw!', } } console.log(RESULTS_MAP[p1][p2]) }
this is a cute way of doing it.
3 u/longknives Dec 01 '22 I don’t think you would need quotes around any of the key names like this. 1 u/Macaframa Dec 01 '22 It’s true. But then again, we wouldn’t do anything like this to begin with
3
I don’t think you would need quotes around any of the key names like this.
1 u/Macaframa Dec 01 '22 It’s true. But then again, we wouldn’t do anything like this to begin with
1
It’s true. But then again, we wouldn’t do anything like this to begin with
15
u/Macaframa Dec 01 '22
this is a cute way of doing it.