Advertisement
Guest User

Untitled

a guest
May 25th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. setTimeout(function(){
  2.  
  3. var todos = ["Buy something"];
  4. var input = prompt ("What would you like to do?");
  5.  
  6.  
  7. while (input !== "quit") {
  8. if (input === "list") {
  9.      list ();
  10. } else if (input === "new") {
  11.       addtodo ();
  12. } else if (input === "delete") {
  13.       deletetodo ();
  14. }
  15.  
  16. //ask again what todo
  17. input = prompt ("What would you like to do?");
  18. }
  19.  
  20. console.log ("OK, you quit... QUITTER!");
  21.  
  22. //functions
  23.  
  24. function list () {
  25. console.log("**********");
  26.     todos.forEach(function(todo, index){
  27.         console.log(index + ": " + todo);
  28.     });
  29.     console.log("**********");
  30. }
  31. function addtodo (){
  32.      var newtodo = prompt ("What would you like to add yo?");
  33.       todos.push (newtodo);
  34.       console.log (newtodo+" added to the list");
  35. }
  36. function deletetodo (){
  37.       var index = prompt ("What do you want to delet fool?");
  38.       todos.splice (index,1);
  39.       console.log (index +"has been deleted");
  40. }
  41.  
  42. //end of window set time out
  43. }, 500);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement