3.1 Variables & Assignments hacks
Categories: Programming Fundamentals TutorialApply your understanding of Variables & Assignments with these hacks
🐷 Peppa Maze Variables & Assignments Hacks
Welcome to the Peppa Maze hacks! These challenges will test your understanding of variables, assignments, and logic in Javascript. Read each task, then write or modify code to solve it.
Hack 1: JavaScript - Variable Assignment, Naming, and Operators
Create variables for Peppa’s name, score, and level using good JavaScript naming conventions. Assign initial values, then use operators to update score (add 10) and level (multiply by 2). Print all results.
// Write your code here
// Create variables for Peppa's name, score, and level
// Use operators to update score and level
Hack 2: JavaScript - Variable Declaration, Assignment, and Operators
Declare variables for Peppa and George’s scores using good JavaScript naming conventions. Assign initial values, then use operators to update both scores (e.g., Peppa gets 15 points, George loses 5 points). Print both scores.
// Write your code here
// Declare variables for Peppa and George's scores
// Use operators to update both scores
Hack 3: JavaScript - Multiple Assignment and Math Operators
Peppa and George both start at level 1. Use a single line to assign both their levels to 5. Then, calculate a combined score by multiplying their levels together and multiplying by 10. Print all results.
// Write your code here
// let peppaLevel = 1, georgeLevel = 1;
// Assign both levels to 5 in one line
// Calculate combinedScore = peppaLevel * georgeLevel * 10;
// Print all results