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

Homework 1 Submission #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
54 changes: 27 additions & 27 deletions exercises.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,138 +2,138 @@

function multiplyByTen(num) {
// return num after multiplying it by ten
// code here
return num * 10;
}

function subtractFive(num) {
// return num after subtracting five
// code here
return num - 5;
}

function areSameLength(str1, str2) {
// return true if the two strings have the same length
// otherwise return false
// code here
return str1.length == str2.length;
}

function areEqual(x, y) {
// return true if x and y are the same
// otherwise return false
// code here
return x === y;
}

function lessThanNinety(num) {
// return true if num is less than ninety
// otherwise return false
// code here
return num < 90;
}

function greaterThanFifty(num) {
// return true if num is greater than fifty
// otherwise return false
// code here
return num > 50;
}

function add(x, y) {
// add x and y together and return the value
// code here
return x + y;
}

function subtract(x, y) {
// subtract y from x and return the value
// code here
return x - y;
}

function divide(x, y) {
// divide x by y and return the value
// code here
return x / y;
}

function multiply(x, y) {
// multiply x by y and return the value
// code here
return x * y;
}

function getRemainder(x, y) {
// return the remainder from dividing x by y
// code here
return x % y;
}

function isEven(num) {
// return true if num is even
// otherwise return false
// code here
return num % 2 == 0;
}

function isOdd(num) {
// return true if num is false
// return true if num is odd
// otherwise return false
// code here
return num % 2 == 1;
}

function square(num) {
// square num and return the new value
// code here
return Math.pow(num, 2);
}

function cube(num) {
// cube num and return the new value
// code here
return Math.pow(num, 3);
}

function raiseToPower(num, exponent) {
// raise num to whatever power is passed in as exponent
// code here
return Math.pow(num, exponent);
}

function roundNumber(num) {
// round num and return it
// code here
return Math.round(num);
}

function roundUp(num) {
// round num up and return it
// code here
return Math.ceil(num);
}

function addExclamationPoint(str) {
// add an exclamation point to the end of str and return the new string
// 'hello world' -> 'hello world!'
// code here
return str.concat('!');
}

function combineNames(firstName, lastName) {
// return firstName and lastName combined as one string and separated by a space.
// 'Lambda', 'School' -> 'Lambda School'
// code here
return ''.concat(firstName, ' ', lastName);
}

function getGreeting(name) {
// Take the name string and concatenate other strings onto it so it takes the following form:
// 'Sam' -> 'Hello Sam!'
// code here
return ''.concat('Hello', ' ', name, '!');
}

// If you can't remember these area formulas then head over to Google or look at the test code.

function getRectangleArea(length, width) {
// return the area of the rectangle by using length and width
// code here
return length * width;
}

function getTriangleArea(base, height) {
// return the area of the triangle by using base and height
// code here
return (0.5 * base * height);
}

function getCircleArea(radius) {
// return the rounded area of the circle given the radius
// code here
return Math.round( Math.PI * Math.pow(radius, 2) );
}

function getRectangularPrismVolume(length, width, height) {
// return the volume of the 3D rectangular prism given the length, width, and height
// code here
return length * width * height;
}

// Do not modify code below this line.
Expand Down
9 changes: 9 additions & 0 deletions explanations.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
1. A variable is a container for values . In the expression 'var x = 5;', x is a variable.

2. A string is a sequence of characters. This form of data can either be mutable or immutable, depending on the programming language. JS strings are immutable.

3. A function is a block of code that is designed to take an input (which could be no input) and returns an output (which could be no output). Arguments are the elements passed into the function as input. Return is the command used in many languages to designate what is outputted by the function.

4. An if statement surrounds a block of code in a condition. If the condition evaluates to true, then the block of code runs. If not, then another condition block might be activated, if there is one.

5. 'True' and 'false' are the only two members of the boolean data type. They represent (respectively) "on" or "off", "yes" or "no", or other related states. The result of a comparison is going to be a boolean value.
Loading