English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I've wrote this script to average for number that user enters . but it doesn't work properly . plz help me with this . here's the script :
-------------------------------------------------------------------------------


function return



showing the return




2006-08-29 23:03:37 · 2 answers · asked by cutie_boy1987 1 in Computers & Internet Programming & Design

2 answers

here's your problem

let's say you have a=1, b=2, c=3, d=4 as you input them in the "prompt"
when you add them a+b+c+d the result will be "1234" (a string) instead of 10 ( a number)

so do it like this

function average(a,b,c,d){
av=(parseInt(a) + parseInt(b) + parseInt(c) + parseInt(d)) / 4;
return av;
}

2006-08-29 23:19:58 · answer #1 · answered by Deep Thought 5 · 0 0

man I dont have time for this find out for yourself

http://www.google.co.uk/search?hl=en&q=javascript+script+to+average+for+number+that+user+enters&btnG=Search&meta=

2006-08-30 06:09:15 · answer #2 · answered by Joe_Young 6 · 0 0

fedest.com, questions and answers