Hi everyone, I need help urgently!
I was charged with resolving the issues with these javascript codes. I am just a starter and therefore, I will need all the help I can get.
I keep getting these error messages:
1. formatTime.js
My First Code:
The Errors: I Get
'hour' is not defined.
'meridies' is not defined.
'minute' is not defined.
'second' is not defined.
2. times.js
My Code:
The Errors I get:
Missing '()' invoking a constructor.
'start_time' is not defined.
'formatted_time' is not defined.
'end_time' is not defined.
'formatted_end_time' is not defined.
'time_change' is not defined.
PLEASE HELP! I am desperate.
Thank you.
I was charged with resolving the issues with these javascript codes. I am just a starter and therefore, I will need all the help I can get.
I keep getting these error messages:
1. formatTime.js
My First Code:
Code:
// formats the current date/time so that it reads as hh:mm:ss PM/AM
function formatTime(time) {
hour = time.getHours();
if (hour>12) {
hour = hour-12;
meridies = "PM";
} else {
meridies = "AM";
}
minute = time.getMinutes();
if (minute<10) {
minute = "0"+minute;
}
second = time.getSeconds();
if (second<10) {
second = "0"+second;
}
return hour+":"+minute+":"+second+" "+meridies;
}
The Errors: I Get
'hour' is not defined.
'meridies' is not defined.
'minute' is not defined.
'second' is not defined.
2. times.js
My Code:
Code:
/* global formatTime: true */
/* Please do not remove the comment above. */
// timer to calculate the starting and stopping clicks
$(document).ready(function() {
$("#start").on('click',function() {
$("#start").addClass("hidden");
$("#stop").removeClass("hidden");
$("#time_ended").addClass("hidden");
$("#time_started").removeClass("hidden");
start_time = new Date;
formatted_time = formatTime(start_time);
});
$("#stop").on('click',function() {
$("#stop").addClass("hidden");
$("#reset").removeClass("hidden");
$("#time_started").addClass("hidden");
$("#time_ended").removeClass("hidden");
end_time = new Date;
formatted_end_time = formatTime(end_time);
$("body").append("<p class='results'>You started at "+formatted_time+".</p>");
$("body").append("<p class='results'>You finished at "+formatted_end_time+".</p>");
time_change = end_time-start_time;
$("body").append("<p class='results'>You counted "+(time_change/1000).tofixed(2)+" seconds.</p>");
$("body").append("<p class='results'>You are off by "+(time_change/1000-45).tofixed(2)+" seconds.</p>");
});
});
The Errors I get:
Missing '()' invoking a constructor.
'start_time' is not defined.
'formatted_time' is not defined.
'end_time' is not defined.
'formatted_end_time' is not defined.
'time_change' is not defined.
PLEASE HELP! I am desperate.
Thank you.