- Joined
- Jan 29, 2020
- Messages
- 18
- Reaction score
- 0
I stuck trying to figure out how to convert hours and min to seconds inside a fucntion ill post my directions and if someone can help give me a better understanding of the formula id really appreciate it.
A function that takes hours, minutes, seconds as parameters, and returns the total number of seconds (convert each to seconds, then add them up)
so far the above code is what ive been able to piece together the numbers at the bottom being used to call the function are just to test if the code works. thank you in advance.
A function that takes hours, minutes, seconds as parameters, and returns the total number of seconds (convert each to seconds, then add them up)
Code:
<!DOCTYPE html>
<html>
<body>
<script>
// javascript code begin
function hms2s( h, m, s) {
var total = h + m + s ;
return total ;
}
document.write(hms2s(2,3,4) );
/*A function that takes hours, minutes, seconds as parameters, and returns the total number of seconds (convert each to seconds, then add them up)*/
// javascript code end
</script>
</body>
</html>
so far the above code is what ive been able to piece together the numbers at the bottom being used to call the function are just to test if the code works. thank you in advance.