JSFiddle - React, Tailwind, and code Playground
by kflorence
JavaScript
// What would this result in and why?
'This is a title'.replace(' ', '_');
// What's wrong here?
var myElements = [ /* DOM Collection */ ];
for (i = 0; i < myElements.length; ++i) {
myElements[i].onclick = function() {
alert('You clicked on: ' + i);
};
}
// What's wrong here?
var arr = [5, 10, 15]
var total = 1;
for (var x in arr) {
total = total * arr[x];
}
// What is the result?
"3" - "1";
2 + "";
typeof null;
typeof [];
// Why does this result in an error?
var Car = function(color) {
this.color = color;
};
var blueCar = Car("blue");
// What is the value of a?
var a;
// Is this valid?
undefined = "surprise!";