Guest User

Untitled

a guest
Mar 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  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. let color_lawn = {
  12. title: "lawn",
  13. color: "#00FF00",
  14. rating: 0
  15. }
  16.  
  17. // function taking two argument, color and rating
  18. // modifying rating property of color and returning color
  19. // object
  20.  
  21. function rateColor(color, rating){
  22. color.rating = rating
  23. return color
  24. }
  25.  
  26. console.log(rateColor(color_lawn, 5).rating)
  27. console.log(color_lawn.rating)
  28.  
  29. var rateColor1 = function(color, rating){
  30. return Object.assign({}, color, {rating:rating})
  31. }
  32.  
  33. console.log(rateColor1(color_lawn, 7).rating)
  34. console.log(color_lawn.rating)
  35. console.log(color_lawn.color)
  36. </script>
  37.  
  38.  
  39.  
  40. <script id="jsbin-source-javascript" type="text/javascript">let color_lawn = {
  41. title: "lawn",
  42. color: "#00FF00",
  43. rating: 0
  44. }
  45.  
  46. // function taking two argument, color and rating
  47. // modifying rating property of color and returning color
  48. // object
  49.  
  50. function rateColor(color, rating){
  51. color.rating = rating
  52. return color
  53. }
  54.  
  55. console.log(rateColor(color_lawn, 5).rating)
  56. console.log(color_lawn.rating)
  57.  
  58. var rateColor1 = function(color, rating){
  59. return Object.assign({}, color, {rating:rating})
  60. }
  61.  
  62. console.log(rateColor1(color_lawn, 7).rating)
  63. console.log(color_lawn.rating)
  64. console.log(color_lawn.color)
  65. </script></body>
  66. </html>
Add Comment
Please, Sign In to add comment