Git Product home page Git Product logo

phase-1-scope-lab's Introduction

Scope Lab

Learning Goals

  • Understand how functions determine scope in JavaScript

Introduction

Scuber's drivers are beginning to take down some notes 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. You'll also need to use var to declare all variables except when specifically instructed otherwise. 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.

Fork and clone this lab into your local environment. Navigate into its directory in the terminal, then run code . to open the files in Visual Studio Code.

Ok, these are your tasks:

  • customerName: Declare a variable in global scope called customerName using the var keyword and assign it the value 'bob'.
  • 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 to 'maybe bob'.
  • leastFavoriteCustomer and changeLeastFavoriteCustomer(): Now declare a constant (using the const keyword) in global scope called leastFavoriteCustomer; be sure to assign it some initial value. Finally, write a function called changeLeastFavoriteCustomer() that attempts to change that constant - notice what JavaScript does when you try to change the constant.

When you're done, remember to commit and push your changes up to GitHub, then submit your work to Canvas using CodeGrade.

phase-1-scope-lab's People

Contributors

alexgriff avatar curiositypaths avatar drakeltheryuujin avatar gj avatar graciemcguire avatar jeffkatzy avatar jlboba avatar lizbur10 avatar maxwellbenton avatar

Stargazers

 avatar  avatar  avatar

Watchers

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

phase-1-scope-lab's Issues

Bothersome when lab instructions ("acceptance criteria") omit reqs and instead discover reqs via 'learn test'

Canvas Link

https://learning.flatironschool.com/courses/5185/assignments/179313?module_item_id=396113

Concern

I'm glad that the instructions for 'setBestCustomer()' state the requirement that 'bestCustomer' should be set to 'not bob'.

It's irritating when the lab instructions don't specify such requirements for functions. It's fine to have generic requirements like:
customerName: Declare a variable in global scope called customerName using the var keyword.
-and-
overwriteBestCustomer() that changes that bestCustomer variable.

but it seems like tests for such generic powers should should set up scaffolding of some sort that tests for the generic functionality. (And "Declare a variable" does not include "and set its value", whether to some string or to a passed argument.) If that's too hard and it's easier to assert that 'bob' is the means for testing that 'upperCaseCustomerName()' converts the global 'customerName' value properly, why not let us know that 'bob' is the test string as part of the lab instructions?

Same for 'overwriteBestCustomer()'. The step requires "changing" the 'bestCustomer' value. My initial assignment to 'billy bob' worked fine. The test should test that the new value is "something", and it's not 'not bob'. If the requirement is for 'maybe bob', why not say so during the specification?

Additional Context

No response

Suggested Changes

Include 'bob' and 'maybe bob' in the lab steps.

Perhaps the intent is to sensitize students that writing tests will naturally use random-looking strings like 'maybe bob', and the programmer's choice of such strings will not have been specified by the client. But if that's the case, maybe we can give a hint: After specifying the generic requirement, include something like "Note: Our test of this feature will look for a value of 'maybe bob'." Or: "Check the 'indexTest.js' file for the value of the string you have to use."

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.