silver-io / javascript-fix-the-scope-lab-bootcamp-prep-000

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JavaScript Fix the Scope Lab

Objectives

  • Explore scope in JavaScript
  • Exercise bug-finding skills related to scope issues

Instructions

In this lab, you'll need to debug some issues related to function scope in JavaScript: variables might not be what we expect, certain variables might be unavailable, and in general havoc might be set loose in the current code.

As usual, start by running the specs and reading the results. Then fix some things, run the tests again, and repeat.

You're probably pretty good at this right now — good luck!

A Hint About ()

Remember the purpose of using () is to call functions in JavaScript. It essentially tells our code to execute the function. A function called without a (), like simply functionName, will return the function but NOT run it. You'll see the return value as [Function: functionName].

To get our code to execute that function, we instead call functionName(), which executes the code within that function.

As an example, the third test here at first returns: Error: Expected [Function: funkyFunction] to equal 'FUNKY!'

We can make the function execute by saying this: var theFunk = funkyFunction() But this returns ANOTHER FUNCTION! How would we tell that function to execute to return the string within it?

Resources

View Fix The Scope Lab on Learn.co and start learning to code for free.

About

License:Other


Languages

Language:JavaScript 77.7%Language:HTML 22.3%