Giter Site home page Giter Site logo

js-primer's Introduction

JS Assignment Primer


In this assignment, students are tasked with implementing a calculateTotal method. This method should receive two parameters (items and tax) and returns a number representing the total cost of all the items including the tax on all items which are taxable.

The items parameter is an array which contains item objects. Each item object has two keys: price and taxable. The first key, price, contains a number which represents the price of the item. The second key, taxable, contains a boolean denoting whether the item is a taxable or non-taxable item respectively.

The tax parameter is a number which represents the tax percentage which should be applied to each taxable item. The value of tax must be a positive number between zero and one. If a negative value is passed in as the tax parameter then the absolute value of that number should be used instead.

Students are given a simple skeleton with a method signature for calculateTotal and are expected to implement the method. All code should be written within the scope of the provided function. After cloning the assignment students need to run the npm install command to install all packages needed to run the included tests. In order to run the included tests students should use the npm test command.

Examples


// Example items array
const items = [
  {
    price: 100,
    taxable: false
  },
  {
    price: 50,
    taxable: false
  },
  {
    price: 250,
    taxable: true
  }
]

// Example call to calculateTotal
calculateTotal(items, .0975) // 100 + 50 + 250 + (250 * .0975) = 424.375

js-primer's People

Contributors

wmarttala avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.