JavaScript Quiz

ResourcefulChrysoberyl avatar
ResourcefulChrysoberyl
·
·
Download

Start Quiz

Study Flashcards

3 Questions

Which of the following is NOT a data type in JavaScript?

Decimal

What is the result of the following code: '5' + 3?

'53'

What is the output of the following code?

var x = 5; function add(num) { var x = 2; return x + num; } console.log(add(3));

7

Study Notes

JavaScript Data Types

  • There are specific data types in JavaScript, but the options are not provided.

String Concatenation

  • In JavaScript, when a string is added to a number using the '+' operator, the number is converted to a string and then concatenated.
  • The result of '5' + 3 is '53'.

Variable Scope and Functions

  • In a function, a variable with the same name as a global variable can be declared, which will have a local scope.
  • The local variable will override the global variable within the function.
  • In the given code, var x is declared globally with a value of 5, but within the add function, another var x is declared with a value of 2.
  • The add function will use the local x value, which is 2, and add the provided num to it.
  • The output of the code will be 5, which is the result of 2 + 3.

Test your knowledge of JavaScript with our quiz! Challenge yourself with questions on data types, string concatenation, and function output. Sharpen your skills and improve your understanding of this popular programming language.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Javascript Quiz
3 questions

Javascript Quiz

BetterFluorite avatar
BetterFluorite
JavaScript Quiz
10 questions

JavaScript Quiz

LawfulCognition avatar
LawfulCognition
JavaScript Quiz
3 questions

JavaScript Quiz

BrandNewRapture avatar
BrandNewRapture
Use Quizgecko on...
Browser
Browser