Challenges Flashcards
Review and Practice
Choose the numbers that are NOT present in this code’s output.
for(let i = 10; i <= 15; i++)
document.write(45 - i + “,”);
Select all that apply
44
34
24
23
44, 24, 23
What is the output of this code? var a=8; var b=9; a=(b%2)+a/(a%3); document.write(a);
5
What is the output of this code? var arr = [5, 6, 8]; var str = (string)arr; var bool = (boolean)str; console.log(bool);
True
False
Error
Error
What will be alerted? function bar() { return foo; function foo() {} var boo = '11'; } alert(typeof bar());
undefined
function
string
number
Function
Fill in the blanks to change the content of the div to “Hi there”.
<div></div>
var d,a;
d=document.getElementById(‘ txt ‘);
a=document.createTextNode(“Hi there”);
d .appendChild( a );
True
What is the output of this code? function changeNum(b) { b = 2; } var a = 3; changeNum(a); alert(a);
Error
2
3
undefined
3
What is the output of this code? for(var x = 0; x == x; x++) { if(x > 5 && x < 8) { document.write(x); break; } }
6
What is the output of this code? function mult(x=10, y=2) { return x / y; } document.write(mult(30));
15
What is the output of this code? if(10 > 9) { document.write("true"); } else { document.write("false"); } false true True False
true
You can write JavaScript code inside HTML document.
True
What is the result of this code?
alert(console.log(“Solo”));
Prints “undefined” in alert box and prints “Solo” in Console.
Error
No output
Prints “undefined” in alert box and prints “Solo” in Console.
What is the output?
document.write(1==”1”);
false
true
True
What is the output of this code? var nums = [1, 2, 3, 4, 5]; var str = ""; for(var i = 0; i < 5; i++) { str += nums[i] + " "; nums.unshift(1); } console.log(str);
1 1 2 3 4
5 4 3 2 1
1 1 1 1 1
1 2 3 4 5
1 1 1 1 1
What is the data type of variable x? let x = true;
undefined
number
string
boolean
boolean
What is the output of this code?
var a =”2”+”8”;
var b = a.replace(“2”,”3”);
alert(b);
38
What is the output of this code? for(var x = 1; x > 0; x++) { if(x > 7) { alert(x); break; } }
8
What is the output of this code? var a = 8; a = a + a / (a % 3); document.write(a);
12
What will be alerted? function prod(a,b,c=3) { x=a*b*c; return x; } result=prod(8,3,5); alert(result);
120