Make your websites go from this:
http://www.legworkstudio.com/
var myName = "Bob";
var number = 1;
var booleanExample = false;
Data, like the values stored in the variables myName, numbers, and booleanExample have types, known as data types.
Can someone name some data types?
'', "" are both fine, however be consistent with your use of quotes; do not switch between single and double
var cat1 = Mr.Whiskers;
DO NOT DO THE FOLLOWING:
var cat = "Mr. Whiskers";
if (cat == "Reynald") {
console.log("died in a tragic car accident");
} else if (cat == "Sammy") {
console.log("killed in a violent fight");
} else if (cat == "Mikey") {
console.log("went up in flames in a gas station explosion");
} else {
console.log("was gluttonous, and choked on a fish bone");
}
var x = 5;
var y = 4;
console.log(x==y);
x = y;
console.log(x);
The expression x==y checks for whether or not x is the same as y
x = y sets the value of x to the value of y
var cat1 = "Mr. Whiskers";
var cat2 = "Sammy";
if (cat1 = cat2) {
console.log(cat1 + " killed " + cat2);
}
var cat1 = "Sammy";
var cat2 = "Reynald"
var cat3 = "Dead";
var cat4 = "Dead";
var catAmount = 4;
if (catAmount >= 4 && cat4 == "Dead") {
if (cat1 = "Sammy") {
console.log("Well, that one's still alive!")
}
if (cat2 !== "Dead" && cat3 !== "Dead") {
console.log("Wow, congrats on the live cats!");
} else {
console.log("Well, I guess some of your cats are dead.");
}
} else {
console.log("What???")
}
Aliens are invading! There are blue, green, and red aliens. The total amount of aliens there are is 10,000.
Create variables with this information, and set up a series of conditional statements such that:
First, check if there are 10,000 aliens. Then,
if there are more than 5,000 green aliens, console.log "Ugh, why are they so ugly?"
If there are more than a total of 8,000 green and red aliens combined, console.log
"No, why?????"
If there are not more than 3000 red and blue aliens combined, console.log
"Okay, this seems somewhat manageable. Wait no, we're still dead..."
You may assign the alien amounts yourself, but the total must add up to ten thousand!