const setUserSelection = (userInput=userInput.toLowerCase()) => {
Within this line, you are setting the default value for the function argument. This default value will be undefined
unless userInput
is present within the scope. It does not alter the argument you provide initially.
For example, consider a function like this:
const greeting = (name="stranger") => console.log(`hello, ${name}`)
When called without any arguments, it will output "hello, stranger". If called as greeting("Scrissors")
, it will output "hello, Scrissors".
Upon calling the function: setUserSelection('Scissors')
, the default argument is replaced by your input, making userInput
within the function equal to "Scissors"
.
To perform the conversion, it should be handled within the function body:
const setUserSelection = (userInput) => {
userInput=userInput.toLowerCase()
/* userInput has now been converted to lowercase based on the argument provided */
}