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
// javascript | |
/*1 Write a function called billTotal that can be used to calculate the total to be paid at a restaurant -- | |
including tip and tax -- given the subtotal (i.e. cost of food and drinks). | |
We can assume that the tip will be 15% and tax will be 9.5%. Make sure that the tip does not include the tax!*? | |
*/ | |
function getTotal(price){ | |
var postTip = (price*0.15)+price; | |
var postTax = (postTip *0.095); | |
return postTip+postTax; | |
} |
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
// javascript | |
/*1Debug each: You are given this function each, but it doesn't work exactly as expected. | |
It should call callback on value, key, and collection respectively for each element of collection, | |
and accept both arrays and objects. Identify everything incorrect with each as it is provided, | |
and modify the function so that it works as expected. Be sure to list all that was incorrect about the original function. | |
*/ | |
var each = function(collection, callback) { | |
if (Array.isArray(collection)){ | |
for (var i = 0; i < collection.length; i++) { | |
collection[i] = callback(collection[i], i, collection); |