0
   

How to add and average user inputted numbers

 
 
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
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 741 • Replies: 0
No top replies

 
 

Related Topics

 
  1. Forums
  2. » How to add and average user inputted numbers
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/25/2024 at 06:58:46