• Master Hun

My Virtual Pet Worksheet #0000

My Virtual Pet Worksheet

Pet owner's name: ____________________

Pet's name: ____________________

Pet type: ____________________

Pet's age: ____________________

Pet's weight: ____________________

Pet's hunger: ____________________

Pet's health: ____________________

Pet's happiness: ____________________

What is a virtual pet?


What is a variable?


What is JavaScript?


My First JavaScript Program

1 // This is a comment. Comments help to explain what the code does.

2 // The following is an example of a variable.

3 // The name (or label) of the variable is petOwnerName.

4 // The value (or data) stored in petOwnerName is the string

5 // "John Doe".

4 var petOwnerName = "John Doe";

5 // The following instruction creates a pop up box.

6 // The pop up box tells you the name of the pet owner.

7 alert("The pet owner's name is " + petOwnerName);

Common Syntax Errors

Incorrect capitalization: Var x = 10;

Correct capitalization: var x = 10;

Var and var are not the same. The keyword var in JS must be in lower case only.

Adding a space between the function name and the parentheses.

Incorrect: myFunction (x, y);

Correct: myFunction(x, y);

Forgetting to end a statement with a semicolon;

Incorrect: x = x + 4

Correct: x = x + 4;

#pythonfumasters #masterhun #javascript

8 views0 comments

Recent Posts

See All