Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript trouble parseFloat and if/ else loop
    primarykey
    data
    text
    <p>So working on some code and I'm not spotting the issue with my loop in the second function it keeps returning 40, I think the loop is written correctly. I'm guessing its the value passed within the if and else condition? if (par_hour &lt; 40) which comes from parseFloat</p> <pre><code> function addEmployee() { var employees = new Array(); employees[0] = window.prompt("Enter employee name","Bob"); var hours = new Array(); hours[0] = window.prompt("Enter How many hours you have slaved away! ","4.5"); var wages = new Array(); wages[0] = window.prompt("Enter your hourly wages.","10.00"); alert("test"); calculateSalary(hours,wages); alert("How about now"); document.write(regHours); } function calculateSalary(hours,wages) { par_hour = parseFloat(hours[0]); par_wage = parseFloat(wages[0]); if (par_hour &lt; 40) { regHours = par_hour; } else (par_hour &gt;= 40) { regHours = 40; } alert("why wont you work"); } &lt;html&gt; &lt;head&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 Salary&lt;/h1&gt; &lt;table border="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;Reg Pay&lt;/th&gt; &lt;th&gt;OT Hours&lt;/th&gt; &lt;th&gt;OT Pay&lt;/th&gt; &lt;th&gt;Weekly Salary&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; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload