JavaScript how to make two variables share a math.random value in javascript

Suceeded in randomizing a quote but now the values name and quote don't match, is there a way to make json.name and json.quote share the same random value? so Einstein's quote isn't matched with the name Nightingale.

let url =;

$.getJSON( url, function( json ) {

let rand = function getRandom() {
return Math.floor(Math.random() * 4) + 1  ;
}

//console.log(rand());

document.write(" "" + json[rand()].quote +""" + "  by " 
+json[rand()].name );


});
Answer:1

Something peculiar is happening for me with jquery-ui. I'm importing several pieces of jquery-ui separately in my HTML: <script type="text/javascript" src="../third-party/jquery-1.10.2/jquery.min....

Something peculiar is happening for me with jquery-ui. I'm importing several pieces of jquery-ui separately in my HTML: <script type="text/javascript" src="../third-party/jquery-1.10.2/jquery.min....

Say I have the following nested immutable data structure: import { Record, List } from 'immutable' const foo = List([ Record({ id: 1, gameState: Record({}) }) ...

Say I have the following nested immutable data structure: import { Record, List } from 'immutable' const foo = List([ Record({ id: 1, gameState: Record({}) }) ...

Does anyone know if it's possible to populate a list of IDs for another model using waterline associations? I was trying to get the many-to-many association working but I don't think it applies here ...

Does anyone know if it's possible to populate a list of IDs for another model using waterline associations? I was trying to get the many-to-many association working but I don't think it applies here ...

  1. waterline populate association

I have a bar chart which use ChartJS that shows data. Based on the bar chart, I have the data: 15, 2, 0, 11. I can see all of these data in the bar, except 0. Is there a possibility to start the bar ...

I have a bar chart which use ChartJS that shows data. Based on the bar chart, I have the data: 15, 2, 0, 11. I can see all of these data in the bar, except 0. Is there a possibility to start the bar ...

  1. chart start with 0