menu

JavaScript Basic Programs for Beginners

JavaScript Basic Programs for Beginners - Important Points


6.

What is the output of the following program?

console.log(10 % 3);

A. 1

B. 3.33

C. 3

D. 0.3

Discuss Work Space

Answer: option a

Explanation:

The output of the code is "1" because 10 divided by 3 leaves a remainder of 1.

7. Which of the following is the correct way to write an if statement in JavaScript?

A. if (condition) { // code }

B. if (condition) then { // code }

C. if (condition) -> { // code }

D. if (condition) = { // code }

Discuss Work Space

Answer: option a

Explanation:

The correct way to write an if statement in JavaScript is by using the syntax "if (condition) { // code }".

8.

What is the output of the following program?

console.log("hello".toUpperCase());

A. HELLO

B. hello

C. hElLo

D. null

Discuss Work Space

Answer: option a

Explanation:

The output of the code is "HELLO" because the toUpperCase() method converts the string to all uppercase letters.

9. Which of the following is NOT a valid JavaScript data type?

A. number

B. string

C. array

D. tuple

Discuss Work Space

Answer: option d

Explanation:

Tuples are not a valid data type in JavaScript.

10.

What is the output of the following code snippet?

console.log(Math.floor(4.7));

A. 4.7

B. 5

C. 4

D. 0.7

Discuss Work Space

Answer: option c

Explanation:

The output of the code is "4" because Math.floor() returns the largest integer less than or equal to a given number.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now