Skip to content

Instantly share code, notes, and snippets.

View TapaniAla's full-sized avatar

TapaniA TapaniAla

  • TaalVision Technologies Oy
  • Oulu, Finland
View GitHub Profile
const toggleTodo = (todo) => {
// not allowed
//todo.completed = !todo.completed;
//this OK
// return {
// id: todo.id,
// text: todo.text,
// completed: !todo.completed
// };
// note the last assign property wins!
const addCounter = (list) => {
//both are OK:
//return list.concat([0]);
return [...list, 0];
};
const removeCounter = (list,index) => {
// not allowed
// list.splice(index, 1);
return [
const counter = (state = 0, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1;
case 'DECREMENT':
return state - 1;
default:
return state;
}
}
const counter = (state = 0, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1;
case 'DECREMENT':
return state - 1;
default:
return state;
}
}
const counter = (state = 0, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1;
case 'DECREMENT':
return state - 1;
default:
return state;
}
}
function counter(state = 0, action) {
switch (action.type) {
case 'INCREMENT':
return state + 1;
case 'DECREMENT':
return state - 1;
default:
return state;
}
}