Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active September 5, 2022 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/6bc4edbe1d0687817c6aeed6b418f2ee to your computer and use it in GitHub Desktop.
Save McLarenCollege/6bc4edbe1d0687817c6aeed6b418f2ee to your computer and use it in GitHub Desktop.
Exercise : Book Discount

Book Discount

Part 1

Draw the Object Diagram for the below book Object.

let book = {
    author: 'Daniel Kahneman',
    title: 'Thinking, Fast And Slow',
    yearPublished: 2012,
    bestseller: false,
    pricePerCountry:
        {
            'Australia': {amount: 20.0, currency: 'AUD'},
            'India': {amount: 500, currency: 'INR'},
            'United States': {amount: 16.5, currency: 'USD'}
        }
};

Part2

Given the book structure above, if the book was published before 2017 and is not a bestseller, reduce the Indian price by 10% and the United States price by 20%.

Hint: Use an if statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment