Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript Q41 #264

Closed
shoke2k opened this issue Aug 10, 2020 · 3 comments · Fixed by #265
Closed

Javascript Q41 #264

shoke2k opened this issue Aug 10, 2020 · 3 comments · Fixed by #265
Assignees
Labels
good first issue Good for newcomers

Comments

@shoke2k
Copy link

shoke2k commented Aug 10, 2020

https://github.com/Ebazhanov/in-quiz-questions/blob/master/javascript/javascript-quiz.md#q41-what-will-this-code-print
In the console print 1, in DOM document.write(f2()); yes, say undefined

@github-actions
Copy link

Hello @shoke2k , thank you for submitting an issue!

@Ebazhanov Ebazhanov added the good first issue Good for newcomers label Aug 10, 2020
@Ebazhanov
Copy link
Owner

@shoke2k you are absolutely right, it is a typical interview question
if we enter this code in the browser console it will print => 1

and I think that the contributor who answered this question also saw undefined, which is not correct since this is the default behavior of the browser to print undefined at the finish of the code run

var v = 1
var f1 = function(){
    console.log(v)
}

var f2 = function(){
    var v = 2;
    f1()
}

f2()

FYI printing result from my browser console:
image

So, @shoke2k let me know if you want to create PR to update the answer to this question

@shoke2k
Copy link
Author

shoke2k commented Aug 10, 2020

It's not neccesary, you can update it

@Ebazhanov Ebazhanov linked a pull request Aug 10, 2020 that will close this issue
@Ebazhanov Ebazhanov self-assigned this Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants