| View previous topic :: View next topic |
| Author |
Message |
JaccTrippa New member

Joined: 18 Dec 2010 Posts: 3 Location: US
|
Posted: Wed Dec 22, 2010 10:01 am Post subject: conditional statements |
|
|
hello all. just kind of curious. how do i make a switch statement with variables that can be a huge range of numbers? like for instance, say that i wanted to make a any number over 100 cause one thing to happen. then i wanted another thing to happen if the number was less than 100? Can you please help me with my logic?!?! This is as far as i have gotten:
var num = "";
var output = "";
switch(num)
{
case 1:
output = "";
break;
case 2:
output = "";
break;
default:
output = "sucks, figure it out";
}
|
|
| Back to top |
|
 |
thecodewall Member

Joined: 26 Dec 2010 Posts: 10
|
Posted: Sun Dec 26, 2010 8:31 am Post subject: |
|
|
| Code: | <html>
<body>
<script type="text/javascript">
var num = 2;
switch(num)
{
case 1:
document.write("A");
break;
case 2:
document.write("B");
break;
default:
document.write("sucks, figure it out");
}
</script>
</body>
</html> |
http://codewall.blogspot.com
Last edited by thecodewall on Tue Jan 04, 2011 10:10 pm; edited 1 time in total |
|
| Back to top |
|
 |
artguytom New member

Joined: 15 Dec 2010 Posts: 4
|
Posted: Sun Dec 26, 2010 2:21 pm Post subject: Why not a simple conditional? |
|
|
I'm kind of a beginner too, but why a switch statement?
Why not just a conditional?
| Code: |
<html>
<body>
<script type="text/javascript">
var num = prompt("Gimme a number.");
if(num > 100) {
document.write(num + " is a pretty big number.");
} else {
document.write(num + " is a smaller number.");
}
</script>
</body>
</html>
|
|
|
| Back to top |
|
 |
JaccTrippa New member

Joined: 18 Dec 2010 Posts: 3 Location: US
|
Posted: Mon Dec 27, 2010 6:05 am Post subject: |
|
|
| you guys are smart and awesome. thanks. artguytom i require your assistance in another manner. can you email me terrelstinnett37@yahoo.com please if you have time. |
|
| Back to top |
|
 |
|