Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project JavaScript Todos Console #18

Open
haydanu opened this issue Jun 26, 2019 · 7 comments
Open

Project JavaScript Todos Console #18

haydanu opened this issue Jun 26, 2019 · 7 comments

Comments

@haydanu
Copy link

haydanu commented Jun 26, 2019

No description provided.

@krowter
Copy link

krowter commented Jun 26, 2019

https://github.com/krowter/project-javascript-todos-console

@aditilham
Copy link

https://github.com/aditilham/project-javascript-todos-console

@trie168
Copy link

trie168 commented Jun 26, 2019

https://github.com/trie168/014-project-javascript-todo

@fadhilahade
Copy link

https://github.com/fadhilahade/project-javascript-todos-console

@dearetta
Copy link

https://github.com/dearetta/project-todos-console

@Sumapraja
Copy link

https://github.com/Sumapraja/project-javascript-todos-console

@haydanu
Copy link
Author

haydanu commented Jun 28, 2019

const todos = [];

function addTodo(todo) {
  return todos.push(todo);
}

function deleteTodo(index) {
  return todos.splice(index, 1);
}

function findTodo(todoList) {
  const theTodo = todos.find(element => element === todoList);
  console.log("ini hasil temuannya", theTodo);
  return theTodo;
}

function updateTodo(oldTodo, newTodo) {
  let theTodoIndex = todos.findIndex(element => element === oldTodo);
  todos.splice(theTodoIndex, 1, newTodo);
  return todos;
}

addTodo("eat");
addTodo("learn");
// deleteTodo(0);
// findTodo("eat");
console.log("todos before update", todos);

updateTodo("learn", "sleep");

console.log("todos after update", todos);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment