javascript problem- undefined numbers. ?

2009-01-04 12:49 am
Ok i have been doing a javascript tut, and have implemented some numbers to be calculated, i have verified them first however once i do the calc its self and post it using the command-

document.writeln(secs_per_year);

For a rundown heres my code so far inclduing the calculations.

<head>
<script language="javascript">
<!--

//load up some variables

var secs_per_min = 60;
var mins_per_hour = 60;
var hours_per_day = 24;
var days_per_year = 365;

//Do some calculations
var secs_per_day=secs_per_min * min_per_hour * hours_per_day;
var secs_per_year=secs_per_day * days_per_year;

//-->
</script>
</head>

I have var the numbers and entered the calcs, and the end result gives "undefined secs per year"

回答 (2)

2009-01-04 1:04 am
✔ 最佳答案
typo found.

the line:
var secs_per_day=secs_per_min * min_per_hour * hours_per_day;

should be:
var secs_per_day=secs_per_min * mins_per_hour * hours_per_day;

Shinkou , u copied me!
2009-01-04 12:57 am
typo found.

the line:
var secs_per_day=secs_per_min * min_per_hour * hours_per_day;

should be:
var secs_per_day=secs_per_min * mins_per_hour * hours_per_day;


收錄日期: 2021-05-01 01:01:05
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20090103164942AASaH0S

檢視 Wayback Machine 備份