Reply
Mon 13 Oct, 2014 08:50 pm
Ok, so I have to do an assignment where on the page you can type in numbers, separated by commas, and then click a button and it will add up your numbers and average them. But I have no idea how to do that. I have the buttons, I have the commas, but I don't know how to add and average user inputted numbers.
//my code
var userInput; //no idea what to do with this
function clearInput() {
userInput.value = "";
}
function runSplit(){
userInput.value; //string
console.log(userInput.value);
var inputArray:string[] = userInput.value.split(',');
console.log(inputArray);
for( var i:number = 0; i < inputArray.length; i++) {
var convertedNumber:number = parseFloat(inputArray);
console.log(convertedNumber);
}
function addNumbers() { //this is where I started
parseInt(document.getElementById().value);
}
}
Thank you