# JavaScript: Problems added in December 2015

complexity: **4** ; importance: **2**; author: **docentmail**

**Question:** What world would be the result for each line?

typeof "John"; typeof 3.14; typeof false; typeof [1,2,3,4]; typeof {name:'John', age:34};

complexity: **1** ; importance: **7**; author: **docentmail**

**Question:** What should be placed instead of dots to have method do (); performed only when **x** does not equal **y** ?

if (x ... y) { do(); }

complexity: **1** ; importance: **7**; author: **docentmail**

**Question:** What is the name of "**=**" operators ?

complexity: **2** ; importance: **6**; author: **docentmail**

**Question:** Give a code fragment that declares a variable, but is not initializing it.

complexity: **2** ; importance: **3**; author: **docentmail**

**Question:** is this a valid JS statement?

var x= "Hello", cat= "Bob", height = 20;

complexity: **2** ; importance: **3**; author: **docentmail**

**Question:** replace the statement

var x= "Hello", cat= "Bob", height = 20;with multiple statements where each statement contains only one "=". And they doing the same.

complexity: **2** ; importance: **8**; author: **docentmail**

**Question:** Is this valid JavaScript code?

var x= "Hello"; x=[1,2,3]; x=5;

complexity: **3** ; importance: **6**; author: **docentmail**

**Question:** Use switch statement and write the code that alert *Today is your day!*

complexity: **1** ; importance: **2**; author: **docentmail, 4luckynikita**

**Question:**Name this char **'**

complexity: **1** ; importance: **5**; author: **docentmail, 4luckynikita**

**Question:**Name the main four arithmetical operations.

complexity: **1** ; importance: **2**; author: **docentmail, 4luckynikita**

**Question:**Assign number value to variable

complexity: **1** ; importance: **3**; author: **4luckynikta**

**Question:**How can you define the text John Doe as a string

complexity: **2** ; importance: **5**; author: **4LUCKYNIKITA**

**Question:** What would the alert say?

x=5 x += 5 + 2 alert ( x ) ;

complexity: **1** ; importance: **3**; author: **docentmail**

**Question:** Give two variants how to access "**name**" property of given **cat** object.

var cat = {name:"Peter", hi:function() {alert("Hello my friend");}}

complexity: **3** ; importance: **6**; author: **docentmail**

**Question:** create object that has a "**name**" field and can alert text "**Hello my friend**" on calling his **hi** method

complexity: **2** ; importance: **5**; author: **docentmail**

**Question:** What would be value of **x**?

var x = 100 / "10";

complexity: **2** ; importance: **5**; author: **docentmail**

**Question:** What would be value of **x**?

var x = 100 / "Apple";

complexity: **2** ; importance: **2**; author: **docentmail**

**Question:** What will return **typeof x;** and **typeof y;**?

var x = 123; var y = new Number(123);

complexity: **2** ; importance: **2**; author: **docentmail**

**Question:**Give two different approaches to create an array

complexity: **2** ; importance: **4**; author: **docentmail**

**Question:** How to assign last element of array **b** to var **x**

complexity: **2** ; importance: **2**; author: **docentmail**

**Question:** Where is a literal in the expression?

var x = 5;

complexity: **5** ; importance: **1**; author: **docentmail**

**Question:** What would be result of execution of expresion?

typeof typeof 123 or the same with parenthis typeof(typeof(123))

complexity: **5** ; importance: **2**; author: **docentmail**

**Question:** how many times method do() would be called?

for (i = 0, j=3; i < j; i++,j-- ) { do(); }

complexity: **2** ; importance: **4**; author: **docentmail**

**Question:** how many times method do() would be called?

for (i = 0; i > 1 ; i++) { do(); }

complexity: **2** ; importance: **4**; author: **docentmail**

**Question:** how many times method do() would be called?

for (i = 0; i < 1 ; i) { do(); }

complexity: **2** ; importance: **5**; author: **docentmail**

**Question:** how many times method do() would be called?

for (i = 0; i < 1 ; i++) { do(); }

complexity: **3** ; importance: **5**; author: **docentmail**

**Question:** Replace with the code fragment, with equals one that only one “.” per line/statement

var rez = document.getElementById("testspan").getAttribute("class").length;

complexity: **2** ; importance: **2**; author: **docentmail**

**Question:** What is the purpose of **typeof** operator?

complexity: **2** ; importance: **2**; author: **docentmail**

**Question:** Question: What will "x" equal?

var x = 16 + 4 + "Volvo";

complexity: **2** ; importance: **2**; author: **4luckynikita, rorp32, DogeLover1337, TimberWolf91**

**Question:** Question: What will "x" equal?

var x = "Volvo" + 16 + 4;

complexity: **1** ; importance: **3**; author: **4luckynikita**

**Question:** Which of the following lines are correct?

var x = 5; var x = // my comment 5 ; var x = 5; // my comment var x = 5 // my comment ; // var x = 5;

complexity: **2** ; importance: **2**; author: **docentmail**

**Question:** what does alert (x[1]); show?

var x = [1,2,3]; var y = x; y[1]=100; alert (x[1]);

complexity: **2** ; importance: **4**; author: **docentmail**

**Question:** what does alert (x); show?

var x = 1; var y = x; y=101; alert (x);