Coder Social home page Coder Social logo

functions-with-parameters's Introduction

Functions With Global Variables

Setup

  1. Navigate to this directory in your terminal.
  2. Run npm install --global jest to install the testing library (if you've already done this, skip this step!).
  3. Preferably in a full-screen terminal, run jest --watch-all to start testing.

Workflow

You'll be working in main.test.js this time!, creating the variables needed with the values asked for, according to the specifications given in the tests. Check your terminal for feedback on which aspect of the problem you have yet to complete, and read the specifications' actual code implementation for extra help; it makes explicit exactly what outputs are expected given the test inputs.

Guidelines:

  • Please do not call the functions; just declare them! You can call them for your own testing purposes, but then either delete or comment out the line.
  • 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 x + y, do NOT set y to equal 11 directly, or say that y should be 5 + 6. Use the variables instead.

Tasks

Let's start by creating our variables so that we can manipulate them later on with functions.

  • Create a variable called x and set it to the value 3.
  • Create a variable called y and set it to the value 10.
  • Create a variable called z and set it to the value 5.
  • Create a variable called name and set it the string version of your first name.
  • Create a variable called greeting and set it to the value 'HEY'.

Now for some functions!

  • Create a function called multiply that takes in one parameter and changes x to the product of x and that parameter.
  • Create a function called modYBy that takes in one parameter, divides y by that parameter, and sets y to the remainder of that division. Look up the JavaScript modulus operator if you don't remember it, because it could sure come in handy here!
  • Create a function called opposite that takes in a parameter and sets z to equal the opposite sign of that parameter. For example, if the function is passed 6, z should be set to -6, and if passed -85, z should be set to 85. Note that we are not "reading" the value of z here. In other words, unlike the other problems here, it doesn't matter what z used to be!
  • Create a variable called makeFullName that takes in a string parameter and sets name to have that string at the end, with a space in the middle.
  • Create a function called yellAt that takes in a string parameter and adds that string to the end of greeting, with a comma and a space in between and an exclamation point at the end. This string concatenation (or "smooshing" in the technical parlance) should be set to be the new value of greeting.

functions-with-parameters'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.