Javasciprt arrow function error

something is preventing this function from work, ive tryed looking at others do it but something isnt budging.

It is very difficult to work with screenshots of code, but I suspect that

|| ... }

your ... in here should actually have a comparison.

1 Like

I got this actaully, what else am i missing?

const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === ‘rock’ || userInput === ‘paper’ || userInput === ‘scissors’) {
return userInput;
} else {
console.log(‘Error!’);
}
};

console.log(getUseChoice(‘Paper’))

I got this actaully, what else am i missing?

const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === ‘rock’ || userInput === ‘paper’ || userInput === ‘scissors’) {
return userInput;
} else {
console.log(‘Error!’);
}
};

console.log(getUseChoice(‘Paper’))

@Ironipad64

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

What are you expecting the function that it is currently not doing?

Note: I am not sure if it is a result of how you pasted the code without using the triple backticks at first, but I notice your strings are not surrounded with straight quotes. This may or may not be the issue. What error shows in your browser console?

Also, I notice you have a typo in the console.log statement. You call a function named getUseChoice, but the function you defined is named getUserChoice.

2 Likes

it seems the typo was the mistake, but where does the backtick need to be used in my function

You do not need to use backticks for your code. The triple backticks on a separate line before and after comment was just to let you know how to post code in a forum post.