Skip to content

Instantly share code, notes, and snippets.

@marciobarrios
Last active November 24, 2020 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save marciobarrios/cde0296513eea3799ac2aad117524779 to your computer and use it in GitHub Desktop.
Save marciobarrios/cde0296513eea3799ac2aad117524779 to your computer and use it in GitHub Desktop.
Practical frontend interview
(function() {
var a = b = 5;
})();
console.log(b);
// 1. What will be printed on the console?
// 2. Rewrite the code to return the same result but with the variable declarations separated
// 3. Enable strict mode to explicitly reference the scope
console.log('hello'.repeatify(3));
// 1. Write a method of String that prints 'hellohellohello'
function test() {
console.log(a);
console.log(foo());
var a = 1;
function foo() {
return 2;
}
}
test();
// 1. What’s the result of executing this code and why
var fullname = 'Rude Ayelo';
var obj = {
fullname: 'Helios Aliaga',
prop: {
fullname: 'Marcio Barrios',
getFullname: function() {
return this.fullname;
}
}
};
console.log(obj.prop.getFullname());
var test = obj.prop.getFullname;
console.log(test());
// 1. What is the result of the following code?
// 2. Fix the previous question’s issue so that the last console.log() prints Marcio Barrios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment