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 #29

Open
wants to merge 6 commits 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
19 changes: 19 additions & 0 deletions explanations
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feynman Writing Prompts - Write out explanations of the following concepts like you are explaining it to a 12 year old. Doing this will help you quickly discover any holes in your understanding. Ask your questions on Slack.
◦ Variables
Variables are used to find values in a computer program. For example, I may have 2 bowls filled with cereal. If I wanted to find out how much cereal is in each bowl, I would write a variable describing each bowl. Then I would write the value (amount of cereal) of each bowl. Depending on what is necessary, simple math would give me a value.

◦ Strings
Strings are values attached to a variable. Usually the string is comprised of both letters and numbers or only letters. An example: #Flex=67THU865 (not actual). When a command of print a variable is given the value of String is shown.

◦ Functions (arguments, return)
A Function instructs the computer what needs to be done. Arguments are contained in Functions for added instructions. The Return feature of a Function tells the computer whether the value of a code can be reused.

◦ if statements
Similar to how Variables can equal a value, a “if statement” tells the computer that if a value is true or false, to print a given statement. Example:
if (5>4){
print “Power”
}

◦ Boolean values (true, false)
A Boolean examines conditional statements for values to determine if it is True or False.
Example: “Coding is cool and fun.” value1=cool, value2=fun, Boolean=and Results=True
216 changes: 216 additions & 0 deletions hw-exercises.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
//Do not change any of the function names

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

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

function areSameLength(str1, str2) {
// return true if the two strings have the same length
// otherwise return false
// if (str1=areSameLength, str2=areSameLength){
print "true";
}
else {
print "false";
}
}


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

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

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

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

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

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

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

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

function isEven(num) {
// return true if num is even
// otherwise return false
// if num=isEven {
print "true";
}
else {
print "false";
}
}

function isOdd(num) {
// return true if num is false
// otherwise return false
// if num=isOdd{
print "true";
}
else {
print "false";
}
}

function square(num) {
// square num and return the new value
// if math.sqrt(num){
return;
}
}

function cube(num) {
// cube num and return the new value
// if math.cube(num){
return;
}
}

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

function roundNumber(num) {
// round num and return it
// math.round(num){
return;
}
}

function roundUp(num) {
// round num up and return it
// math.roundUp(num){
return;
}
}

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

function combineNames(firstName, lastName) {
// return firstName and lastName combined as one string and separated by a space.
// 'Lambda', 'School' -> 'Lambda School'
// var firstName = 'firstName'
// var lastName = 'lastName'
// var fullName ='firstName + lastName'{
return;
}
}

function getGreeting(name) {
// Take the name string and concatenate other strings onto it so it takes the following form:
// 'Sam' -> 'Hello Sam!'
// var That's my = 'That's my'
// var name = 'name'
// var getGreeting = 'That's my + 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
// var l = 'length'
// var w = 'width'
// var (l * w) = 'area' {
return;
}
}

function getTriangleArea(base, height) {
// return the area of the triangle by using base and height
// var b = 'base'
// var h = 'height'
// var ((b * h)/2) = 'area'{
return;
}
}

function getCircleArea(radius) {
// return the rounded area of the circle given the radius
// var r = 'radius'
// var pi = 'math.pi'
// var (pi * r * r) = 'area'{
return;
}
}

function getRectangularPrismVolume(length, width, height) {
// return the volume of the 3D rectangular prism given the length, width, and height
// var l = 'length'
// var w = 'width'
// var heigh = 'height'
// var (l * w * h) = 'volume'{
return;
}
}