Last active
November 19, 2020 09:53
-
-
Save skarankevich/f429e5b8c416981ccff1 to your computer and use it in GitHub Desktop.
FE Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
console.log(abc); | |
var abc = "abc"; | |
console.log(myFunc()); | |
function myFunc() { | |
var def = abc + 'def'; | |
return def; | |
} | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loop() { | |
for (var i = 0; i < 5; i++) { | |
setTimeout(function() { | |
console.log(i); | |
}, i * 1000); | |
} | |
} | |
loop(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('chai').assert; | |
var greetings = (function createMessages() { | |
var messages = []; | |
for (var i = 0; i < 10; i++) { | |
messages.push(function () { | |
return `Hi! I am ${i}`; | |
}); | |
} | |
return messages; | |
})(); | |
// Let's try | |
try { | |
assert.equal(greetings[0](), 'Hi! I am 0'); | |
assert.equal(greetings[7](), 'Hi! I am 7'); | |
console.info('OK'); | |
} catch (e) { | |
console.warn(e.message); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
console.log(1); | |
setTimeout(function() { | |
console.log(2); | |
}, 1000); | |
setTimeout(function() { | |
console.log(3); | |
}, 0); | |
console.log(4); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// const intersection = () => {}; | |
const firstInput = [9, 2, 3, 5, 8, 9]; | |
const secondInput = [3, 5, 7]; | |
const output = intersection(firstInput, secondInput); | |
const output = [3, 5]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Array.prototype.map | |
const persons = [ | |
{ | |
id: 1, | |
name: "John Smith", | |
}, | |
{ | |
id: 2, | |
name: "Sam Nilson", | |
} | |
]; | |
function transformPersons(persons) { | |
... | |
} | |
console.log(transformPersons(persons)); | |
// [{ | |
// id: 1, | |
// firstName: "John", | |
// lastName: "Smith" | |
// }, ...] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const assert = require('chai').assert; | |
function getOddNumbers(numbers) { // odd numbers | |
return []; | |
} | |
// Let's try | |
try { | |
assert.deepEqual(getOddNumbers([ 1, 2, 3, 4 ]), [ 1, 3 ]); | |
assert.deepEqual(getOddNumbers([ 2, 4, 6, 8 ]), []); | |
assert.deepEqual(getOddNumbers([ 4, 6, 7, 13 ]), [ 7, 13 ]); | |
console.info('OK'); | |
} catch (e) { | |
console.warn(e.message); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function func() { | |
this.name = "John"; | |
} | |
const a = func(); // a? this? | |
const b = new func(); // b? this? | |
const c = { | |
name: "Sam", // do not modify | |
sayName: function () { | |
console.log(this.name); | |
} | |
} | |
const d = ...; | |
d(); // => "John" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment