var timeNow = new Date();
var hours = time.getHours() > 12 ? time.getHours() - 12 : time.getHours();
hours = hours < 10 ? "0" + hours : hours;
function functionHours(){
if(hours > 12) {
return (time.getHours()-12)
} else {
if(hours < 10 && hours > 12) {
return ("0" + hours)
} else {
return (hours)
} else {
return (time.getHours())
}
}
}
I would to convert the ternary operations into if else statements, I've stored the statements on the functions unfortunately it returns an error unexpected token else
. What I would like to do is to add 0 to the hours if the hour is 1-9 (E.g. 09, 08, 05, etc...) What seems to be the problem?