GithubHelp home page GithubHelp logo

fewpjs-js-fundamentals-scope-lab-seattle-web-career-042219's Introduction

JavaScript Fundamentals: Scope Lab

Learning Goals

  • Use const and let to fix the scope in JavaScript

Introduction

ES6 gives us new ways to declare variables that help us out with scoping. The var keyword defines a variable globally or locally to an entire function regardless of block scope. With const and let, declaring variables with var is generally discouraged. 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 the current code might be a little chaotic.

Use const and let to Fix the Scope in JavaScript

To review:

  • A variable or function that is not declared inside a function or block is the global execution context.
  • let variables are block-scoped, and allows you to declare variables that are limited in scope to the block, statement, or expression on which it is used
  • const is also block-scoped restricts over-writing variables. It does not mean the value it holds is immutable, just that the variable identifier cannot be reassigned. const variables also cannot be declared a without assigning its (constant) value
  • Variables declared with var are not block-scoped, and leaves room for error

In index.js, we've given you some starter code. As is, it does not run. Start by running the specs and reading the results. Debug and make some fixes in the code. Run the tests again and repeat. Using your knowledge of scope, access and change the variables until all tests pass. Make sure to focus on using const and let and avoid usage of var, or you may experience some unexpected issues.

Resources

fewpjs-js-fundamentals-scope-lab-seattle-web-career-042219's People

Contributors

drakeltheryuujin avatar jenmyers avatar

Watchers

 avatar

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.