Unary Operators in JavaScript
📖 Scenario: You are working on a simple calculator app that needs to handle increasing and decreasing numbers by one. This is common in counters, like counting items in a shopping cart or tracking steps in a game.
🎯 Goal: Build a small program that uses unary operators to increase and decrease a number by one.
📋 What You'll Learn
Create a variable with an initial number
Create a variable to hold the incremented number using the increment operator ++
Create a variable to hold the decremented number using the decrement operator --
Print the original, incremented, and decremented numbers
💡 Why This Matters
🌍 Real World
Counters are everywhere: counting clicks, items in a cart, or steps in a game. Unary operators make these tasks simple and fast.
💼 Career
Understanding unary operators is essential for writing clean and efficient code in many programming jobs, especially in frontend and backend development.
Progress0 / 4 steps