daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest May 23rd, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta charset="utf-8">
  5.   <meta name="viewport" content="width=device-width">
  6.   <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. function sale(items) {
  12.   let price = {
  13.     'cat': 5,
  14.     'sofa': 10,
  15.     'cheese': 1,
  16.     'snow': 2,
  17.     'snow=2': 0
  18.   }
  19.   let total = 0
  20.   for (let item of items) {
  21.     let current = price[item]
  22.     total = total + current
  23.   }
  24.   return total
  25. }
  26.  
  27.  
  28.  
  29.  
  30.  
  31. let result_1 = sale(['cat', 'sofa'])
  32. console.log(result_1)
  33.  
  34.  
  35. let result_2 = sale(['cheese', 'snow=2', 'snow', 'cat', 'snow'])
  36. console.log(result_2)
  37. </script>
  38.  
  39.  
  40.  
  41. <script id="jsbin-source-javascript" type="text/javascript">function sale(items) {
  42.   let price = {
  43.     'cat': 5,
  44.     'sofa': 10,
  45.     'cheese': 1,
  46.     'snow': 2,
  47.     'snow=2': 0
  48.   }
  49.   let total = 0
  50.   for (let item of items) {
  51.     let current = price[item]
  52.     total = total + current
  53.   }
  54.   return total
  55. }
  56.  
  57.  
  58.  
  59.  
  60.  
  61. let result_1 = sale(['cat', 'sofa'])
  62. console.log(result_1)
  63.  
  64.  
  65. let result_2 = sale(['cheese', 'snow=2', 'snow', 'cat', 'snow'])
  66. console.log(result_2)
  67. </script></body>
  68. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top