Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width">
- <title>JS Bin</title>
- </head>
- <body>
- <script id="jsbin-javascript">
- //todo list
- function createTodoList(list){
- return list;
- }
- function addTodoItem(list,todoItem){
- list.push(todoItem);
- return list;
- }
- function removeTodoItem(list,todoItem){
- let findItem = function (item) {
- return item !=todoItem;
- }
- let newList = list.filter(findItem);
- return newList;
- }
- const myList = createTodoList(["sleep","party"]);
- console.log("createTodoList",myList);
- console.log("addTodoItem",addTodoItem(myList,"wash dishes"));
- console.log("removeTodoItem",removeTodoItem(myList,"sleep"));
- console.log("myList end state",myList);
- </script>
- <script id="jsbin-source-javascript" type="text/javascript">//todo list
- function createTodoList(list){
- return list;
- }
- function addTodoItem(list,todoItem){
- list.push(todoItem);
- return list;
- }
- function removeTodoItem(list,todoItem){
- let findItem = function (item) {
- return item !=todoItem;
- }
- let newList = list.filter(findItem);
- return newList;
- }
- const myList = createTodoList(["sleep","party"]);
- console.log("createTodoList",myList);
- console.log("addTodoItem",addTodoItem(myList,"wash dishes"));
- console.log("removeTodoItem",removeTodoItem(myList,"sleep"));
- console.log("myList end state",myList);
- </script></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement