Skip to content

Instantly share code, notes, and snippets.

@sechastain
Forked from lukealbao/QuickJSQuestion.js
Created May 28, 2019 16:30
Show Gist options
  • Save sechastain/e0aaf35547224ea7204a4a135e4d6b93 to your computer and use it in GitHub Desktop.
Save sechastain/e0aaf35547224ea7204a4a135e4d6b93 to your computer and use it in GitHub Desktop.
Quick JS Question
var inventory = {
'000001': {
name: 'Banana Slicer',
price: 2.99
},
'000002': {
name: 'Three Wolves Tea Cozy',
price: 14.95
}
};
function tenPercentOffOf (obj) {
obj.price = Math.round(0.9 * obj.price * 100) / 100;
return obj;
}
// INSTRUCTIONS
//
// Please refer to the following Javascript variable declaration. When submitting your
// application, please answer the following three questions at the top of your cover
// letter, before any salutations or headings.
//
// var bargainBananaSlicer = tenPercentOffOf(inventory['000001']);
//
// Question 1: After declaring that variable, what is the value of bargainBananaSlicer.price?
// Question 2: After declaring that variable, what is the price of the Banana Slicer
// in the inventory object?
// Question 3: Can you suggest ways to improve this code?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment