Practice Question

Practice Question

Qs. Find the errors in the following code?

Common Coding Errors in JavaScript and How to Fix Them

When writing JavaScript code, small mistakes can lead to unexpected errors or bugs. Here, we’ll explore common issues with variable declarations and assignments, and how to correct them.


1. Variable Naming Errors

Invalid Example:

let 1age = 5; ❌ Error
let 2age = 10; ❌ Error

valid Example:

let age1 = 5; ✅ Correct
let age2 = 10; ✅ Correct

2. Variable Naming Errors

Invalid Example:

let marks = 75; ❌ Error
let is pass = true; ❌ Error

valid Example:

let marks = 75; ❌ Error
let is pass = true; ❌ Error

3. Variable Naming Errors

Invalid Example:

let ispass = 'true'

valid Example:

let ispass == true