Javascript trouble parseFloat and if/ else loop -


Then working on some code and I'm not opening this problem with my loop in another function, it's back to 40 I think the loop is written correctly. I'm guessing its value and passed within the other situation? If (par_hour> 40) comes from parseFloat

prefix function addEmployee () {var employees = new array (); Employees [0] = window.prompt ("Enter the employee's name", "Bob"); Var hours = new array (); Hour [0] = window.prompt ("How many hours to enter!", "4.5"); Var wages = new array (); Wages [0] = window.prompt ("Enter your hourly wages", "10.00"); Warning ("test"); CalculateSalary (hours, wages); Warning ("How about now"); Document.write (regHours); } Function calculation salary (hours, wages) {par_hour = parseFloat (hours [0]); Par_wage = parseFloat (wages [0]); If (par_hour & lt; 40) {regHours = par_hour; } And (para_hor> = 40) {regHours = 40; } Alerts ("Why do not you work"); } & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Matt Beckley Week 2 assignment & lt; / Title & gt; & Lt; Script type = "text / javascript" src = "script1.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; H1 & gt; Weekly Gross Pay & lt; / H1> & Lt; Table range = "1" & gt; & Lt; TR & gt; & Lt; Th & gt; Employees & lt; / Th & gt; & Lt; Th & gt; Total hours & lt; / Th & gt; & Lt; Th & gt; Reg Hours & lt; / Th & gt; & Lt; Th & gt; Regular pay & lt; / Th & gt; & Lt; Th & gt; OT hours & lt; / Th & gt; & Lt; Th & gt; OT Payment & lt; / Th & gt; & Lt; Th & gt; Weekly pay & lt; / Th & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; A href = "salary.html" id = "reload" onclick = "addEmployee ();" & Gt; Add Employees & lt; / A & gt; & Lt; / Body & gt; & Lt; / Html & gt;

If you are missing if and < Remove the condition from the second part of the statement (as if the situation is unnecessary: ​​if it is not less than 40, then it will be greater than or equal to 40) or if it is else if (para_hor> = 40)

  else {regHours = 40; } // or else if (par_hour> = 40) {regHours = 40; }  

Part of the return statement was edited, it seems that you are using global variable. I recommend returning a value and instead suggest using the global variable.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -