0% found this document useful (0 votes)
15 views3 pages

JS Debugging Upload

The document contains a series of code snippets with associated questions regarding errors and issues in JavaScript. Each snippet highlights a specific programming mistake, such as syntax errors, scope issues, and logical errors in loops and functions. The document serves as a guide for identifying common pitfalls in JavaScript coding.

Uploaded by

66ds4xcn9f
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

JS Debugging Upload

The document contains a series of code snippets with associated questions regarding errors and issues in JavaScript. Each snippet highlights a specific programming mistake, such as syntax errors, scope issues, and logical errors in loops and functions. The document serves as a guide for identifying common pitfalls in JavaScript coding.

Uploaded by

66ds4xcn9f
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

What is wrong with the following code?

function sayHello() {

console.log "Hello World!";

==

Identify the error

let x = 5

if(x > 3) {

console.log("x is greater than 3")

==

Why does this throw an error?

let name = "Alice";

console.log(Name);

==

Why does this code cause an error?

console.log(myVar);

let myVar = 10;

==

Why does this function return undefined?

function multiply(a, b) {

a * b;

console.log(multiply(2, 3));

==

What happens when calling this function?

function addNumbers(a, b) {
return a + b;

console.log(addNumbers(2));

==

What is the issue with this loop?

for (let i = 0; i < 5; i-- ) {

console.log(i);

==

Why is map() not returning the expected array?

let arr = [1, 2, 3, 4];

let doubled = arr.map(num => { num * 2 });

console.log(doubled);

==

What is wrong with this forEach loop?

let numbers = [1, 2, 3, 4];

numbers.forEach(num => {

if (num % 2 === 0) break;

});

==

What is the error:

let i = 1;

while (i <= 5) {

console.log(i);

==

What is the error:


for (let i = 0; i < 3; i--) {

console.log(i);

==

What is the error:

for (let i = 0; i <= 10; i += 2); {

console.log(i);

You might also like