GithubHelp home page GithubHelp logo

js-principles-scope-chain-code-along-v-000's Introduction

JavaScript Practice Scope Lab

Objectives

  1. Understand the difference between const and let
  2. Understand how functions determine scope in Javascript

Introduction

Scuber's drivers are beginning to take some notes down about their customers. Use your knowledge of scope to access and change some of these variables.

Instructions

A word of warning. In this lab, you will practice doing some bad things. For example, we'll ask you to declare variables in global scope, and write functions that break down. We do this, because by testing the limits, and exposing the underbelly of a language you can better understand it, and know what to avoid in the future.

Ok, this is your task.

  • customerName: Declare a variable in global scope called customerName using the var keyword.

  • upperCaseCustomerName: Write a function that accesses that global customerName variable, and uppercases it.

  • setBestCustomer: Write a function that when called, declares a variable called bestCustomer in global scope and assigns it to be 'not bob'. (Poor bob.) Also, poor us, declaring a global variable from inside a function is one of those things we would never want to do normally, but is good for us to explore right now.

  • overWriteBestCustomer: See the consequences of declaring a variable in global scope, by writing a new function called overWriteBestCustomer that changes that bestCustomer variable.

  • leastFavoriteCustomer and changeLeastFavoriteCustomer: Now declare a constant in global scope called leastFavoriteCustomer customer. Ok, now write a function called changeLeastFavoriteCustomer that attempts to change that constant - notice what Javascript does when you try to change the constant.

  • attemptTwoFavoriteCustomers: Now write another function that will break down. Try declaring a variable called favoriteCustomer and redeclaring that same variable such that an error is thrown. This helps illustrate how let only allows a given variable to be declared one time, but that variable can be re-assigned to a different value. However, const does not allow re-assignment, nor does it allow the same constant to be declared more than once.

js-principles-scope-chain-code-along-v-000's People

Contributors

gj avatar hansenjl avatar maxwellbenton avatar

Watchers

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

js-principles-scope-chain-code-along-v-000's Issues

Typo

"Understand functions determine scope in Javascript" should be "Understand how functions determine scope in Javascript"

Code for this lesson is already provided

I know this is a 'code-along' so perhaps this is intentional, but all of the code to pass the tests in this lab is provided. The last commit message says 'Copy over existing lesson as a placeholder.'

lesson expects passing tests but learn gem doesn't recognize the test included in repo

Hello, when I run 'learn' in bash, the console gives an error saying there are no tests available, making it impossible to complete. To fix this, I simply deleted the package-lock.json file and added the following lines in package.json:

"scripts": {
"postinstall": "gem install learn-co",
  "test": "node_modules/browser-sync/bin/browser-sync.js start --config node_modules/learn-browser/bs-config.js"
}

Also, I updated the value of the "learn-browser" key to "^0.1.13".
With that it worked, I just wanted to alert someone of this. I submitted a pull request with these changes (last regarding this: the package.json file seems to have other wrong info in it. Seems like it was copy/pasted from another lesson, but I didn't update that stuff).

Finally, I want to suggest that this lesson should actually be excised from the javascript section, since it is essentially a repeat of the Scope Lab. Thanks for your consideration!

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.