Skip to content

Instantly share code, notes, and snippets.

@mhosier
Created April 17, 2019 04:41
Show Gist options
  • Select an option

  • Save mhosier/3ea2b2646ef9c8b019b3f04462cbe856 to your computer and use it in GitHub Desktop.

Select an option

Save mhosier/3ea2b2646ef9c8b019b3f04462cbe856 to your computer and use it in GitHub Desktop.
self-assessment-2.js
function lesserNum(num1, num2) {
// YOUR CODE HERE
if (num1 === num2) {
return num1;
} else
if (num1 < num2) {
return num1;
} else
if (num2 < num1) {
return num2;
}
}
lesserNum(19, 4); //4
// lesserNum(3, 26); //3
// lesserNum(-10, -10); //-10
function isHotdogASandwich(input) {
// return boolean true for everything
if (input === undefined) {
return true;
} else
if (input !== undefined) {
return "Alright, MAYBE. Who\'s to say?";
}
}
// isHotdogASandwich(); //true
isHotdogASandwich("Well, if you consider these arguments.."); //"Alright, MAYBE. Who's to say?"
// isHotdogASandwich(42); //"Alright, MAYBE. Who's to say?"
function billTotal(subTotal) {
//Do not worry about rounding to 2 decimal places
var total = subTotal + (subTotal*.09875) + (subTotal*.20);
return total;
}
billTotal(120); //155.85
// billTotal(200); //259.75
function budgetStatus(cost) {
var status = undefined;
if (cost <= 250) {
return status = "Under budget by " + (250-cost) + " dollar(s)";
} else
if (cost > 250) {
return status = "Over budget by " + (cost-250) + " dollar(s)";
}
return status;
}
var day1Expenditures = 155;
var day2Expenditures = 411;
var day3Expenditures = 249;
budgetStatus(day1Expenditures); //Under budget by 95 dollar(s)
// budgetStatus(day2Expenditures); //Over budget by 161 dollar(s)
// budgetStatus(day3Expenditures); //Under budget by 1 dollar(s)
function secondsConverter(seconds) {
//If it is greater than 60 minutes, do not worry about converting it to hours.
// seconds % 60 then the remainder is the leftover seconds
var minutes = Math.round(seconds / 60);
var seconds = (seconds % 60);
return (minutes + " minutes and " + seconds + " seconds");
}
secondsConverter(300); //"5 minutes and 0 seconds"
// secondsConverter(5225); //"87 minutes and 5 seconds"
// secondsConverter(18); //"0 minutes and 18 seconds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment