Coder Social home page Coder Social logo

functions-ahoy's Introduction

Functions With Global Variables

Setup

  1. Navigate to this directory in your terminal.
  2. Run npm install --global jest if you have not yet done so to install the testing library.
  3. Preferably in a full-screen terminal, run jest --watch-all to start testing.

Workflow

You'll be working in main.test.js, creating the variables and functions needed, according to the specifications given in the Tasks section below. Check your terminal for feedback on which aspect of the problem you have yet to complete!

Guidelines:

  • Please do not call the functions; just declare them! You can call them to check for your own testing purposes, but then either delete or comment out the line. (Because our test code runs your function and modifies the global variables, checking if the variable has been changed to the value we'd expect, if you're calling your function and changing it ALSO, the test code will change the value a second time and, when it goes to check the value, it will not be what the test code is expecting.)
  • If you are asked to define a variable in terms of another, do not recalculate the value of that variable. For example, if x = 5, and y = 6, and z is supposed to be the sum of x + y, do NOT set y to equal 11 directly. Use the x and y variables directly in that calculation instead.

Tasks

Let's start by creating our variables so that we can manipulate them later on with functions. Create those variables at the top of your file, OUTSIDE of any functions.

Variables
  • Create a variable named x and assign to it the value 3.
  • Create a variable named y and assign to it the value 10.
  • Create a variable called z and assign to it the value of 4.
  • Create a variable called greeting and assign to it the string 'hello'.
  • Create a variable called firstName and assign to it the string of your name.
  • Create a variable called callStatus and assign to it the string 'ringing'.

Now let's make these variables useful by writing some functions!

Functions
  • Create a function named double and have it double the value of x.
  • Create a function named triple and have it triple the value of y.
  • Create a function named square and have it square the value of z.
  • Create a function named beNice and have it change the value of greeting to the string 'hello' plus your name using the value of the variable firstName. You can include other characters if you wish to make it look like a nice sentence.
  • Create a function named changeName and have it change the value of firstName to the string 'Danger'.
  • Create a function named hangUp and have it change the value of callStatus to the string 'call ended'.

functions-ahoy's People

Contributors

abbreviatedman avatar ruthmoyano 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.