i am trying to iterate through a string and remove all of the spaces. The js console is telling me this about line 1: Uncaught SyntaxError: Unexpected end of input.
userinput is connected to an input tag with the id "number"
any ideas would be appreciated.
userinput = $('input#number').val();
function thing(x) {
for (i = 0; i <= x.length(); i++) {
if (x.charAt(i) === (" ")) {
return x.indexOf(i).replace("")
}
}
$(document).ready(function() {
$('form#factorial').submit(function(event) {
console.log(thing(userinput));
event.preventDefault();
});
});
}