Not a function TypeError when trying to split a user input inside a function
The argument to splitUserInput
should be the input value, not the array that you pushed it onto.
splitUserInput
should return the result of splitting, and then you can push that onto data.sp;littedInput
.
function updateUserInput(data) {
if (data.userInput.length == 0) {
// console.log("You can do this Panda!")
data.userInput.push(input.value);
//input.value is what a user inputs in a textarea.
data.splittedInput.push(splitUserInput(data.userInput));
}
}
function splitUserInput (userInputParam){
let splittedInput = userInputParam.split(/([*/+-])/)
return splittedInput;
}