Submissions will no longer be placed on the leaderboard. You may still attempt this problem for practice.

Explanation

A data type is a classification identifying types of data such as string, boolean or numbers. It determines the possible values for that particular type.

JavaScript Data Types

Here's a useful video related to the topic:

JavaScript is a loosely typed or a dynamic language. That means you don't have to declare the type of a variable ahead of time.

The latest ECMAScript standard defines seven data types:

► Six data types that are primitive:

  • Number
  • Boolean
  • String
  • Symbol (new in ECMAScript 6)
  • Null
  • Undefined

► and an Object

To learn about the difference between primitive data types and objects, click here.


Numbers

Numbers can be written with or without decimals. They can also be written in scientific (exponential) notation.

EXAMPLE

var num1 = 42;      //Written without decimals. 
var num2 = 42.00;   //Written with decimals.
var num3 = 2e5;     //200000
var num4 = 2e-5;    //0.00002

Booleans

Boolean can only have two values: true or false.

EXAMPLE

var a = true;   
var b = false;

Strings

A string is written with quotes. It can be written using single or double quotes.

EXAMPLE

var website = "hackerrank";   // Using double quotes
var website = 'hackerrank';   // Using single quotes

Symbol

A symbol is a unique and immutable data type and may be used as an identifier for object properties. To create a new primitive symbol, you simply write Symbol() with an optional string as its description.

EXAMPLE

var sym = Symbol();
var sym1 = Symbol("foo");

Null

In JavaScript, null is "nothing". It is supposed to be something that doesn't exist.

EXAMPLE

var data = null;

Undefined

In JavaScript, a variable without a value has the value, undefined. Also, any variable can be emptied by setting the value to undefined.

EXAMPLE

var data;       //It has type undefined
var data1 = undefined;

Object

An object is a collection of properties. The properties are identified by using key values. Property keys are used to access the properties and their values.

Object properties are written as key:value pairs separated by commas.

EXAMPLE

var car = {color:"black", model:"X", mileage:30};

Task

Your task is to:

  • Create a variable my_num and assign it any number.
  • Create a variable my_bool and assign it any boolean.
  • Create a variable my_str and assign it any string.
Line: 1 Col: 1
  1. Challenge Walkthrough
    Let's walk through this sample challenge and explore the features of the code editor.1 of 6
  2. Review the problem statement
    Each challenge has a problem statement that includes sample inputs and outputs. Some challenges include additional information to help you out.2 of 6
  3. Choose a language
    Select the language you wish to use to solve this challenge.3 of 6
  4. Enter your code
    Code your solution in our custom editor or code in your own environment and upload your solution as a file.4 of 6
  5. Test your code
    You can compile your code and test it for errors and accuracy before submitting.5 of 6
  6. Submit to see results
    When you're ready, submit your solution! Remember, you can go back and refine your code anytime.6 of 6
  1. Check your score