Skip to content

Instantly share code, notes, and snippets.

@boisbb18
boisbb18 / Self-Assessment3
Created June 11, 2017 21:48
Boiskhon Bakhodirov
// 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);
@boisbb18
boisbb18 / self-assessment1.js
Created June 1, 2017 03:54
Boiskhon Bakhodirov
// 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;
}