Hi, I can't figure out what I'm doing wrong here. It must be the simplest thing, but the script is meant to add asterisks only after the numbers 1, 2, or 3. Instead it is appending one to each number.
Please help.

<SCRIPT LANGUAGE="JavaScript">

var number=1;
var is1or2or3;

function checkIf1or2or3(n){
    if (n==1||n==2||n==3){is1or2or3=true;}
    else {is1or2or3=false;}
}

while (number<=10)
{
document.write(number);
checkIf1or2or3(number);
if (is1or2or3=true){document.write("*");}
document.write("</br>");
number++;
}

</script>

line 15...

if (is1or2or3=true)

needs to use the comparison double equals == as the single equals is for assignment, and an assignment statement will always evaluate to true.

Aha! Thank you!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.