Created
July 2, 2019 03:39
-
-
Save yenisbel/ced0cba943e3367e05b7b98adaab4818 to your computer and use it in GitHub Desktop.
Yenisbel Valle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Execerses 1 | |
function lesserNum(num1, num2) { | |
if (num1 < num2) return num1; | |
return num2 | |
} | |
console.log(lesserNum(9, 5)) | |
console.log(lesserNum(2, 3)) | |
// Exer2 | |
function isHotdogASandwich(input) { | |
if(input) return `Alright, MAYBE. Who's to say?` | |
return true | |
} | |
console.log(isHotdogASandwich('lolo')) | |
console.log(isHotdogASandwich()) | |
//Exerci3 | |
function billTotal(subTotal) { | |
let saleTax = 0 | |
let tipAmount = 0 | |
saleTax = (subTotal * 9.875)/100; | |
tipAmount = (subTotal * 20)/100; | |
return subTotal + saleTax + tipAmount | |
} | |
console.log(billTotal(120)) | |
// Exers4 | |
function budgetStatus(cost) { | |
if(cost < 250){ | |
return `Under budget by ${250 - cost} dollar(s)` | |
}else{ | |
return `Over budget by ${cost - 250} dollar(s)` | |
} | |
} | |
console.log(budgetStatus(155)) | |
console.log(budgetStatus(411)) | |
// Exer5 | |
function secondsConverter(seconds) { | |
//If it is greater than 60 minutes, do not worry about converting it to hours. Cause 60 seconds = 1min | |
if (seconds < 60 ){ | |
return `0 minutes and ${seconds} seconds` | |
}else{ | |
return `${seconds/60} minutes and ${seconds % 60} seconds` | |
} | |
} | |
console.log(secondsConverter(300)) | |
console.log(secondsConverter(5225)) | |
// Exer6 | |
function arrayInfo(arr){ | |
return `Length: ${arr.length}, index of last element: ${arr.length - 1}` | |
} | |
console.log(arrayInfo([true])) | |
console.log(arrayInfo(['true', 'falsy','lolo'])) | |
// Exerc7 | |
function acronymMaker(wordBank) { | |
//You can assume the first letter of each string in the array is capitalized | |
let strWord = ''; | |
wordBank.forEach(element => { | |
strWord += element[0].toUpperCase() | |
}); | |
return strWord | |
} | |
console.log(acronymMaker(["World", "Health", "Organization"])) | |
// Exerc8 | |
function getCurrentLocation(person) { | |
// let strLocation = '' | |
return `${person['city']}, ${person['state']}` | |
} | |
let locateMe = { | |
name: "Lana Bartlett", | |
age: 48, | |
work: { | |
title: "Product Manager", | |
tenure: "3 years" | |
}, | |
city: "Redmond", | |
state: "Washington" | |
} | |
console.log(getCurrentLocation(locateMe)) | |
// Exerc9 | |
function multiplyBy(numberArray, factor) { | |
// YOUR CODE HERE | |
let resultArrFactor = []; | |
for (let i = 0; i < numberArray.length; i++) { | |
let newValue = numberArray[i] * factor | |
resultArrFactor.push(newValue) ; | |
} | |
return resultArrFactor | |
} | |
console.log(multiplyBy([2,4,6,8], 2)) | |
// Exerc10 | |
function iValidatedThis(objectToCheck) { | |
objectToCheck['dataChecked'] = true; | |
objectToCheck['checkedBy'] = 'Yenisbel' | |
} | |
let objYeni = { 'lastname': 'Valle', 'age': 34 , 'color': 'blue'} | |
iValidatedThis(objYeni) | |
console.log(objYeni) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment