First Round:
1. function random(){
return {value: 20}
}
const ah = random();
const bn = new random();
console.log(ah) // 10
console.log(bn) // {value: 20}
2. create a memorized function
Solution:
function memoise(fn){
var cache = {};
return function(){
const key = JSON.stringify(arguments);
if(cache[key]){
console.log("already there", cache[key])
return cache[key]
} else {
val = fn.apply(null, arguments)
cache[key] = val;
console.log("its new", val);
return val;
}
}
}
3. create a triangle using css and HTML
solution:
.arrow-up{
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 100px solid blue;
}
4. Clouser, promise questions, new keyword instances in JS