Giter Site home page Giter Site logo

js-functions-01's Introduction

Intro to Functions

Getting Started

  1. Fork this repo and git clone it down to your computer
  2. Create two files index.html and script.js
  3. Include script.js in index.html using a <script> tag
  4. Open index.html in your web browser and open the console
  5. After answering each section below, git commit your work
  6. When you're finished or when time is up, push your work to your remote repo, and file a Pull Request.

The Introduction

Write a function named greetings that:

  • takes 1 argument, a name
  • when called for example greetings('Skitter') should console.log "Nice to meet you Skitter!"
  • when called for example greetings('Tattletale') should console.log "Nice to meet you Tattletale!"

How Much Land

Write a function called howMuchLand that:

  • takes 2 arguments: length and width
  • when called, it multiplies the length and width to calculate the area of land
  • returns an output similar to below
console.log(howMuchLand(30, 20)) // -> "You have this many square metres of land: 600"

Which Number is Bigger?

Write a function named greaterNum that:

  • takes 2 arguments, both numbers.
  • returns whichever number is the greater (higher) number.
  • Call that function 2 times with different number pairs, and console.log the output to make sure it works (e.g. "The greater number between 5 and 10 is 10.").

Grade Assigner

Write a function named assignGrade that:

  • takes 1 argument, a number score.

  • returns a grade for the score, either "A", "B", "C", "D", or "F".

  • Call that function for a few different scores and log the result to make sure it works.

    A few examples:

    assignGrade(83) // -> returns "A"
    assignGrade(68) // -> returns "C"
    assignGrade(52) // -> returns "D"

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.