Giter Club home page Giter Club logo

js-functions's Introduction

#Javascript Function Exercises

Create 20 functions by following the comments in functions.js. Write all of functions below in functions.js

Getting Started

  1. Clone this repository and change your current working directory to this repository
  2. Install all dependencies by running the command: npm install
  3. Your work will be done in the file named: functions.js
  4. Run your tests with the command: npm test
  5. Your tests are broken, fix them!

numberToString(Number)

Converts a number a string.

Parameters

n: number

Returns: string, the number as a string

increase(n)

Adds one to a given number

Parameters

n: number

Returns: number

decrease(n)

Subtracts one from a given number

Parameters

n: number

Returns: number

add(x, y)

Adds two numbers.

Parameters

x: number

y: number

Returns: number, the sum

subtract(x, y)

Subtracts the second number from the first.

Parameters

x: number

y: number

Returns: number, the difference

multiply(x, y)

Multiplies two numbers.

Parameters

x: number

y: number

Returns: number, the product

divide(x, y)

Divides the first number by the second.

Parameters

x: number

y: number

Returns: number, the quotient

square(x)

Multiplies a number by itself.

Parameters

x,: number, number to be squared

Returns: number, squared

calculate(operation, x, y)

Prints out the equation: (i.e.) "1 + 5 = 6" or "8 / 2 = 4". Returns the result.

Parameters

operation: string, "add", "subtract", "multiply", or "divide"

x: number

y: number

Returns: number, the result

isGreaterThan(a, b)

Returns true if a is greater than b

Parameters

a: number

b: number

Returns: boolean, a is larger than b

isLessThan(a, b)

Returns true if a is less than b

Parameters

a: number

b: number

Returns: boolean, a is smaller than b

areEqual(a, b)

Returns true if a and b are equal

Parameters

a: number

b: number

Returns: boolean, the numbers are equal

minimum(x, y)

Returns the smallest value of two numbers.

Parameters

a: number

b: number

Returns: number, the smallest number

maximum(x, y)

Returns the largest value of two numbers.

Parameters

a: number

b: number

Returns: number, the largest number

isEven(n)

Returns true if n is even.

Parameters

n: number

Returns: boolean, the number is even

isOdd(n)

Returns true if n is odd.

Parameters

n: number

Returns: boolean, the number is odd

letterGrade(score, total)

Returns a letter grade. "A": 90-100% "B": 80-89% "C": 70-79% "D": 60-69% "F": 0-59%

Parameters

score: number

total: number, maximum possible score

Returns: string, the score represented as a letter grade

incrementReviews(restaurant)

Checks if a restaurant object has a reviews field. If it does, increase it by 1. If it does not, set its reviews field to 1.

Parameters

restaurant: object, represents a restaurant

combine(word1, word2)

Joins two strings with a space.

Parameters

word1: string

word2: string

Returns: string, joined the words joined with a space

createCircle(radius)

Returns a circle object with the properties circumferance and area.

Use Math.PI for the value ฯ€.

Parameters

radius: number

Returns: object, circle


js-functions

After all your tests pass, practice calling functions by following the comments in script.js.

js-functions's People

Contributors

thgaskell avatar mrbarbasa avatar theremix avatar julzbond avatar

Watchers

James Cloos avatar  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.