Coder Social home page Coder Social logo

js_ordering-food's Introduction

Ordering food

Here are 10 items of food:

  • Apple
  • Bread
  • Carrot
  • Dumplings
  • Eggs
  • Fish
  • Garlic
  • Honey
  • Ice cream
  • Jam

Create store.js. Export:

  • store
  • actions: { MOVE_UP, MOVE_DOWN, SELECT, }
  • (*) actionCreators: { moveUp, moveDown, select }
const { store, actions } = require('store');

const initialState = store.getState();
store.dispatch({ type: actions.SELECT, index: 0 });
store.dispatch({ type: actions.MOVE_DOWN });
store.dispatch({ type: actions.MOVE_DOWN });

const updatedState = store.getState();

cosole.log('Should be true', initialState.items[0] === updatedState.items[2]);

Deprecated

Make an app that would allow sorting them in an arbitrary order. It should work as follows:

  1. There are two buttons, "Move Up" and "Move Down". They are initially disabled.
  2. The user selects one of the food items by clicking on it. The buttons become enabled.
  3. By clicking "Move Up", the user moves the selected item one position up, and by clicking "Move Down", the user moves the item one position down. The item should not loose selection when moving. Once it’s become the topmost in the list, disable the "Move Up" button again. Similarly, when the last item on the list is selected, the "Move Down" button must become disabled. In other words, make buttons enabled if and only if clicking on them would have an effect.
  4. The user can then select and start moving a different item.
  5. When the user clicks outside the list, the active item must become unselected.

Create your project as a simple HTML page that uses Redux (link to redux.min.js).

First decide what will be stored in your state, what types of actions you will use and what exact data the actions will include, if any. Then implement a reducer. After all that is done you can move on to writing the rest of the code.

js_ordering-food's People

Contributors

yuriiholiuk avatar gitkurmax avatar danmysak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.