Note that there are some explanatory texts on larger screens.

plurals
  1. POCode printing out multiple answers
    text
    copied!<p>I'm doing some stuff for my JScript class and I can't see how my code is printing multiple instances of my document.write. Any help?</p> <pre><code>memberNumber = prompt("How many people will be staying?"); memberOfAAA = prompt("Are the members part of AAA?"); roomView = prompt("Do you want a room with a view?"); Number(memberNumber); if(memberOfAAA === "yes" || "Yes", memberNumber &gt; 5 &amp;&amp; memberNumber &lt; 3, roomView === "yes") { roomCost = (costRoom12 - (costRoom12 * percent1)+(costRoom12 * viewCost)); document.write("Total cost per night is $" + roomCost ); }if (memberOfAAA === "yes" || "Yes", memberNumber &gt; 5 &amp;&amp; memberNumber &lt; 3, roomView === "no" || "No") { roomCost = (costRoom12 - (costRoom12 * percent1)); document.write("Total cost per night is $" + roomCost );} if(memberOfAAA === "no" || "No" , memberNumber &gt; 5 &amp;&amp; memberNumber &lt; 3, roomView === "yes" || "Yes") { roomCost = (costRoom12 + (costRoom12 * viewCost)); document.write("Total cost per night is $" + roomCost ); }if(memberOfAAA === "no" || "No" , memberNumber &gt; 5 &amp;&amp; memberNumber &lt; 3, roomView === "no" || "No") { roomCost = (costRoom12); document.write("Total cost per night is $" + roomCost ); } if (memberOfAAA === "yes" || "Yes", memberNumber &gt; 5 &amp;&amp; memberNumber &lt; 3, roomView === "yes" || "Yes") { roomCost = (costRoom34 - (costRoom34 * percent2) + (costRoom34 * viewCost)); document.write("Total cost per night is $" + roomCost ); } if (memberOfAAA === "yes" || "Yes", memberNumber &gt; 5 &amp;&amp; memberNumber &lt; 3, roomView === "no" || "No") { roomCost = (costRoom34 - (costRoom34 * percent2)); document.write("Total cost per night is $" + roomCost ); } if(memberOfAAA === "no" &amp;&amp; memberNumber &gt; 5 &amp;&amp; memberNumber &lt; 3, roomView === "yes" || "Yes") { roomCost = (costRoom34 + (costRoom34 * viewCost)); document.write("Total cost per night is $" + roomCost ); } if(memberOfAAA === "no" || "No", memberNumber &gt; 5 &amp;&amp; memberNumber &lt; 3, roomView === "no" || "No") { roomCost = costRoom34; document.write("Total cost per night is $" + roomCost ); } if(memberOfAAA === "Yes" || "yes", memberNumber &gt; 7 &amp;&amp; memberNumber &lt; 4, roomView === "yes" || "Yes") { roomCost = (costRoom56 - (costRoom56 * percent3) + (costRoom56 * viewCost)) } if(memberOfAAA === "yes" || "Yes", memberNumber &gt; 7 &amp;&amp; memberNumber &lt; 4, roomView === "no" || "No") { roomCost = (costRoom56 - (costRoom56 * percent3)); document.write("Total cost per night is $" + roomCost ); } if(memberOfAAA === "no" || "No", memberNumber &gt; 7 &amp;&amp; memberNumber &lt; 4, roomView === "yes" || "Yes") { roomCost = (costRoom56 + (costRoom56 * viewCost)); document.write("Total cost per night is $" + roomCost ); } if(memberOfAAA === "no" || "No", memberNumber &gt; 7 &amp;&amp; memberNumber &lt; 4, roomView === "no" || "No") { roomCost = (costRoom56); document.write("Total cost per night is $" + roomCost ); } </code></pre> <p>It's supposed to only print one string as defined by the variables one inputs, but it's printing out all the strings.</p>
 

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