Code Monkey home page Code Monkey logo

functions-and-variables-quiz's Introduction

Functions and Variables

???

Functions and Variables Quiz

Read through the code snippets carefully before answering the questions below. After you've read the code and corresponding question, we recommend testing your assumptions by running the code before answering. Repl.it is a good place to test each code snippet.

?: What does the following function call log to console:

function log() {
  console.log(greeting);
  var greeting = 'Hello!';
}
log();

( ) 'Hello!' (X) undefined ( ) 'undefined is not a function'

?: What does the following function call log to console:

log();
function log() {
  console.log(greeting);
  var greeting = 'Hello!';
}

( ) 'Hello!' (X) undefined ( ) 'undefined is not a function'

?: What does the following function call log to console:

log();
var log = function() {
  console.log(greeting);
  var greeting = 'Hello!';
}

( ) 'Hello!' ( ) greeting (X) undefined OR 'log is not a function'

?: What does the following function log to console:

function log(s) {
  var s = 'Mr. X';
  console.log(s);
}
log('Hello!');

( ) 'Hello!' (X) 'Mr. X' ( ) undefined ( ) 'undefined is not a function'

???

functions-and-variables-quiz's People

Contributors

maxwellbenton avatar pletcher avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

functions-and-variables-quiz's Issues

Console returns undefined

When I type the following into the Chrome Console it returns 'undefined' which was the wrong answer for the quiz question #3. I selected undefined as that is what is returned in the console but the apparent correct answer for the question is 'log is not a function'

log(); var log = function() { console.log(greeting); var greeting = 'Hello!'; }

Questions

Q1) Maybe my JS is weak, but shouldn't this hoist greeting?

Perhaps it's the difference between running it in a js file and checking it in the console.

Q4) Answer is "log is not defined(โ€ฆ)" not "undefined is not undefined"

Incorrect quiz answer?

In the Functions and Variables Quiz, question 3 asserts that 'log is not a function' is the correct answer. However, when you copy and paste the code into the console, all that is returned is 'undefined'. Nowhere in the console does it log that "log is not a function". Here is the code in question:

log();
var log = function() {
console.log(greeting);
var greeting = 'Hello!';
}

question 3

this is the functions and variables quiz ...the answer is wrong because it say that it is 'undefined' in console..
but the correct answer is coming up saying that 'log is not function'

Quiz seems to be in wrong place

This quiz mainly covers the concept of hoisting. So I think that this lesson/quiz should be moved to the end of the 'functions and scopes' section after the hoisting lesson.

Question #3

When I put the code into console and run it I get undefined, not 'log is not a function'.

Am I missing something?

screen shot 2017-09-17 at 6 56 53 pm

Cant figure out the funkyFunction solution

I submitted the following:

var funkyFunction = function() {
return function() {
return "FUNKY!"
}
}

// We want 'funkyFunction' on the line below to return a function that returns "FUNKY!" -- how can we accomplish that?
// NOTE: To pass this final test, you only need to modify the code below this line.
var theFunk = funkyFunction ()

Not sure how to solve it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.