Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- setTimeout(function(){
- var todos = ["Buy something"];
- var input = prompt ("What would you like to do?");
- while (input !== "quit") {
- if (input === "list") {
- list ();
- } else if (input === "new") {
- addtodo ();
- } else if (input === "delete") {
- deletetodo ();
- }
- //ask again what todo
- input = prompt ("What would you like to do?");
- }
- console.log ("OK, you quit... QUITTER!");
- //functions
- function list () {
- console.log("**********");
- todos.forEach(function(todo, index){
- console.log(index + ": " + todo);
- });
- console.log("**********");
- }
- function addtodo (){
- var newtodo = prompt ("What would you like to add yo?");
- todos.push (newtodo);
- console.log (newtodo+" added to the list");
- }
- function deletetodo (){
- var index = prompt ("What do you want to delet fool?");
- todos.splice (index,1);
- console.log (index +"has been deleted");
- }
- //end of window set time out
- }, 500);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement