JSFiddle - React, Tailwind, and code Playground

by Maxim_Wolf

JavaScript

const POINT_COUNT = 20;
const types =["taxi", "bus", "train", "ship", "drive", "flight", "check-in", "sightseeing", "restaurant"];

const randomInt = (max)=>Math.floor(max*Math.random());

const randomElement = (array)=> array[randomInt(array.length)]

const randomType = ()=>randomElement(types);
const randomCity = () => 'Paris';

const generator = (id)=>({
  "base_price": 1100,
  "date_from": "2019-07-10T22:55:56.845Z",
  "date_to": "2019-07-11T11:22:13.375Z",
  "destination": randomCity(),
  "id": "0",
  "is_favorite": false,
  "offers":[],
  "type": randomType()
});

const points = Array.from({length:POINT_COUNT},(_,id)=>generator(id));
console.log(points);

console.log(points[12]['base_price'])