Help with number program I am writing

I used .charAt to look for the third digit in the number to stop it from subtracting 40 except in the case that the number entered for the startTime is an hour that is on the hour.

Hello. I’ve been away from FCC for awhile because I have been busy, but I have not stopped working on my program. Its a lot of code so I made it into a codePen. Here is the link:

I have gotten most of the bugs out of it by now (i’ve been coding since maybe August in JS I work in the trades). I really enjoy the algorithm scripting part of JS the most, and my program does that.

The problem I am having here is that the actualHoursF() function is supposed to tally up the simulated hours and give you a value in the simActual box. I think I’m doing something stupid. When you click the “calculate” button, it populates the simulated totals, but I have multiple event listeners on that button, and actualHoursF() is one of them. If you click the button again, the actualHoursF() function adds the sim totals up, but by then my other functions are poulating the table with new data that doesn’t match what the actualHours total is. It lags behind by one cycle. If someone could help me I’d be really happy.

The other problem is I’m getting NaN sometimes in my sim totals. I notice it only happens when newEndTime() produces a positive integer. newEndTime basically takes the end time that is entered in endTimeEntry and randomly adds or subtracts a number between 0 and 3 to it, giving a simulated time. I also should mention that newStartTime does the same thing for the startTimeEntry. my “cleanUpXXX” functions are there to go from base 10 math and convert into base 60 math by subtracting 40 in certain conditions, and leaving it alone in other conditions. There is 4 of those, two for the manually entered times and two for the simulated times that it comes up with. Also there is a function all the way at the bottom called “newSimStart” and what that does is it starts at line 2, and overwrites the simulated start time with the end time from the previous iteration (pretty cool huh :slight_smile:) This makes it more realistic. Thanks ahead of time guys I know its a lot of code and its not written very well. Also I have some dumb variable names I know I shouldn’t do this but I was being lazy. Thanks!!

Pretty sure this old thread is dead.

Each reply to the thread brings it to the top, so it is still alive as ever.

Update: I have solved the cycling question by myself. It was simply the way my functions were sequenced. I have them all firing simultaneously now. just need to figure out the NaN problem and it will be perfect, but at this point is usable.