JavaScript Variable Declaration

AchievableTortoise avatar
AchievableTortoise
·
·
Download

Start Quiz

Study Flashcards

10 Questions

Which of the following is NOT a valid way to declare a variable in JavaScript?

var 1z = true;

Which option correctly declares a string variable in JavaScript?

var y = 'hello';

Which variable name is not valid in JavaScript?

2z

Which of the following correctly initializes a boolean variable in JavaScript?

var isTrue = true;

Which syntax error would occur when declaring a variable using the keyword 'var'?

var 1z = true;

ما هي الطريقة الصحيحة لاستخدام عامل الربط لدمج سلسلتين نصيتين في JavaScript؟

"Hello"+"world"

ما هو بناء جملة عبارة if-else في JavaScript؟

if (شرط) { كود } else { كود }

ما هي الوحدة التي ليست وحدة قياس صالحة في CSS؟

lb

ما هو التأشير الصحيح لأهم عنوان في HTML؟

h1

هل يمكن للمستخدمين تعيين تفضيلات المتصفح الخاصة بهم؟

صح

Study Notes

Declaring Variables in JavaScript

  • Variable y can be declared with the keyword var and assigned a string value, such as "hello".
  • Variable x can be declared with the keyword var and assigned a numeric value, such as 5.
  • Identifier 1z is not a valid variable name in JavaScript, as it starts with a number.
  • There is no such keyword as Ovar in JavaScript to declare a variable, so D-Ovar a is an invalid declaration.

JavaScript Variables

  • var 1z = true is not a valid way to declare a variable in JavaScript.
  • Valid variable declarations include var y = "hello" and var x = 5.

JavaScript String Concatenation

  • The correct way to use the concatenation operator to combine two strings is "Hello " + "world".

JavaScript If-Else Statements

  • The syntax for an if-else statement is if (condition) { code block } else { code block }.

CSS Units of Measurement

  • lb is not a valid unit of measurement in CSS.
  • Valid units of measurement in CSS include cm, px, em, and others.

Browser Preferences

  • Users can set their own browser preferences, making True the correct answer.

HTML Headings

  • The most important heading should be marked up as h1.
  • Headings in HTML should follow a hierarchical structure, with h1 being the most important and h6 being the least important.

This quiz tests your understanding of how to declare variables in JavaScript. Identify the invalid way to declare a variable in JavaScript.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free
Use Quizgecko on...
Browser
Browser