Status: Not Started
  • scratchpad.js
  • Unit Test
Font Size
14
Parentheses autocomplete
Wrap lines
Editor
Theme
Code with blocks by default
Auto-Format
Console Font Size
12
Console Theme
Show File Tab Bar
Code Running Environment

Use the newest vesion of the JavaScript library.

Vending Machine
Unit Test
function getSnackPrice(type, size) {
// Your code here
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Output
Grading
Docs
Exercise
More
 
Pass Test Message

Errors:

This student is viewing this assignment in English. View this page in English?

5 points

Youre helping program a vending machine that sells snacks. Each snack has a different price depending on its type and size. Use the chart below to determine the price (in cents):

  • Chips: small = 100, medium = 150, large = 200
  • Chocolate: small = 120, medium = 170, large = 220
  • Cookies: small = 90, medium = 140, large = 190

Write a function getSnackPrice that takes in the type of snack and the size, and returns the corresponding price. If the combination is invalid, return -1.

The function should take two parameters:
- type (string)
- size (string)

It should return an integer representing the snack price.

Reset Code

Slides and Notes

No slides available for this video

About

JavaScript (function)