Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 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. //todo list
  12.  
  13. function createTodoList(list){
  14. return list;
  15. }
  16.  
  17. function addTodoItem(list,todoItem){
  18. list.push(todoItem);
  19. return list;
  20. }
  21.  
  22. function removeTodoItem(list,todoItem){
  23. let findItem = function (item) {
  24. return item !=todoItem;
  25. }
  26.  
  27. let newList = list.filter(findItem);
  28.  
  29. return newList;
  30. }
  31.  
  32. const myList = createTodoList(["sleep","party"]);
  33.  
  34. console.log("createTodoList",myList);
  35.  
  36. console.log("addTodoItem",addTodoItem(myList,"wash dishes"));
  37.  
  38. console.log("removeTodoItem",removeTodoItem(myList,"sleep"));
  39.  
  40. console.log("myList end state",myList);
  41. </script>
  42.  
  43.  
  44.  
  45. <script id="jsbin-source-javascript" type="text/javascript">//todo list
  46.  
  47. function createTodoList(list){
  48. return list;
  49. }
  50.  
  51. function addTodoItem(list,todoItem){
  52. list.push(todoItem);
  53. return list;
  54. }
  55.  
  56. function removeTodoItem(list,todoItem){
  57. let findItem = function (item) {
  58. return item !=todoItem;
  59. }
  60.  
  61. let newList = list.filter(findItem);
  62.  
  63. return newList;
  64. }
  65.  
  66. const myList = createTodoList(["sleep","party"]);
  67.  
  68. console.log("createTodoList",myList);
  69.  
  70. console.log("addTodoItem",addTodoItem(myList,"wash dishes"));
  71.  
  72. console.log("removeTodoItem",removeTodoItem(myList,"sleep"));
  73.  
  74. console.log("myList end state",myList);
  75. </script></body>
  76. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement