Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mika #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Mika #27

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 80 additions & 23 deletions functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,74 @@
* @return {string} the number as a string
*/


function numberToString(n) {
return n + '';
}
/**
* Adds one to a given number.
* @param {number} n
* @return {number}
*/

function increase(n) {
return n + 1;
}

/**
* Subtracts one from a given number.
* @param {number} n
* @return {number}
*/

function decrease(n) {
return n -1;
}

/**
* Adds two numbers.
* @param {number} x
* @param {number} y
* @return {number} the sum
*/

function add(a,b) {
return a + b;
}

/**
* Subtracts the second number from the first.
* @param {number} x
* @param {number} y
* @return {number} the difference
*/


function subtract(x,y) {
return x-y;
}
/**
* Multiplies two numbers.
* @param {number} x
* @param {number} y
* @return {number} the product
*/

function multiply(x,y) {
return x * y;
}

/**
* Divides the first number by the second.
* @param {number} x
* @param {number} y
* @return {number} the quotient
*/

function divide(x,y) {
return x/y;
}

/**
* Multiplies a number by itself.
* @param {number} x, number to be squared
* @return {number} squared
*/

function square(n) {
return n * n;
}

/**
* Performs a mathematical operation on two numbers.
Expand All @@ -66,61 +81,76 @@
* @param {number} y
* @return {number} the result
*/


function mathematical(x,y) {

}
/**
* Returns true if `a` is greater than `b`.
* @param {number} a
* @param {number} b
* @return {boolean} `a` is larger than `b`
*/

function isGreaterThan(a,b) {
return a>b;
}

/**
* Returns true if `a` is less than `b`.
* @param {number} a
* @param {number} b
* @return {boolean} `a` is smaller than `b`
*/

function isLessThan(a,b) {
return a<b;
}

/**
* Returns true if `a` and `b` are equal.
* @param {number} a
* @param {number} b
* @return {boolean} the numbers are equal
*/

function areEqual(a,b) {
return a === b;
}

/**
* Returns the smallest value of two numbers.
* @param {number} x
* @param {number} y
* @return {number} the smallest number
*/

function minimum(x,y) {
return x <= y ? x : y;
}

/**
* Returns the largest value of two numbers.
* @param {number} x
* @param {number} y
* @return {number} the largest number
*/

function maximum(x,y) {
return x >= y ? x : y;
}

/**
* Returns true if `n` is even.
* @param {number} n
* @return {boolean} the number is even
*/

function isEven(n) {
return n % 2 === 0;
}

/**
* Returns true if `n` is odd.
* @param {number} n
* @return {boolean} the number is odd
*/

function isOdd(n) {
return n % 2 !== 0;
}

/**
* Returns a letter grade.
Expand All @@ -133,7 +163,19 @@
* @param {number} total maximum possible score
* @return {string} the score represented as a letter grade
*/

function letterGrade(score, total) {
var percent = score / total;
if (percent >= .90)
return 'A';
else if (percent >= .80)
return 'B';
else if(percent >= .70)
return 'C';
else if(percent >= .60)
return 'D';
else
return 'F';
}

/**
* Checks if a `restaurant` object has a `reviews` property.
Expand All @@ -142,15 +184,24 @@
* @param {object} restaurant represents a restaurant object
* @return {object} restaurant
*/


function incrementReviews(restaurant) {
if (restaurant.reviews) {
restaurant.reviews++;
}
else {
restaurant.reviews = 1;
}
return restaurant;
}
/**
* Joins two strings with a space.
* @param {string} word1
* @param {string} word2
* @return {string} joined the words joined with a space
*/

function combine(word1, word2) {
return word1 + ' ' + word2;
}

/**
* Returns a circle object with the properties `circumference` and `area`.
Expand All @@ -159,4 +210,10 @@
* @param {number} radius
* @return {object} circle
*/

function createCircle(radius) {
var circle = {
circumference: 2 * Math.PI *radius,
area: Math.PI * (radius * radius)
}
return circle;
}