Unsectioned

Preview this deck

How do you create a function?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

5

All-time users

6

Favorites

0

Last updated

5 months ago

Date created

Nov 16, 2020

Cards (18)

Unsectioned

(18 cards)

How do you create a function?

Front

function MyFunction() {

      \\Some code goes here. 

}

Back

How do you access nested arrays?

Front

You use multiple brackets indicating where you are trying to access. eg.

 

var MyArray = [[0,1,2,],[3,4,5],[6,7,8]]

 

var SomeData = MyArray [1][0]

 

This would set SomeData to be the number 3

Back

How do you append to the end of an array?

Front

Use the push function.  

 

var MyArray = ['a','b','c','d']

 

MyArray.push(['e','f','g'])

Back

How do you remove something from the beginning of an array?

Front

Use the shift function.  

 

var MyArray = ['a','b','c','d']

 

MyArray.shift()

 

that removes that first item in the array so it will look like this. 

var MyArray = ['b','c','d']

Back

how do you write a switch statement?

Front

switch(val) {

   case 1:

      answer="alpha"

      break;

   case 2:

      answer = "beta"

      break;

}

return answer;

 

Back

What is the and operator in and if statement?

Front

&&

e.g.

if  (val <=50 && val >= 25) {

    return"Yes";

}

Back

Difference Var, Let and Const? 

Front

Var can be used anywhere, Let in the scope of where it was created and Const is a variable that can't be changed. 

Back

How do you remove something from the end of an array?

Front

Use the pop function.  

 

var MyArray = ['a','b','c','d']

 

MyArray.pop(])

 

that removes that last item in the array. 

Back

How would you print variable A?

Front

console.log(A)

Back

How do you use quotes inside a string?

Front

Use the \ before the quotation marks. You can also use single quote or tilde when making the string. 

Back

What is a ternary operator?

Front

Shorthand for a if statement if one true false condition. e.g.

 

a == b ? console.log("Yes, they match" ) : consol.log("nope");

Back

How do you make a comment?

Front

// for single line 

/* for multiline 

Back

Can multiple inputs give the same output in a switch statement?

Front

Yes, by omiting the break and having the answer at the end of the block. e.g.

 

switch(val) {

   case 1:

   case 2:

   case 3:

      answer='Low'

     break;

}

Back

What is the or operator in an if statement?

Front

||

e.g.

if (val >10 || val<5) {

   return "between";

}

Back

What is a default in a switch statement?

Front

Similar to an else in an if statement and should go at the end.

Back

How do you append to the beginning of an array?

Front

Use the unshift function.  

 

var MyArray = ['a','b','c','d']

 

MyArray.unshift('First letter')

 

That adds that first item in the array so it will look like this. 

var MyArray = ['First letter','a','b','c','d']

Back

What is a switch statement?

Front

A switch statement is like an if statement but is shorter to write and looks for a strict match (===)

Back

Can arrays be nested?

Front

Yes, like this

 var MyArray=[[4,5,6],[13216,1,31]] 

Back