pre style color 000000 background ffffff span style color 0000ff font-

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<pre style="color:#000000;background:#ffffff;"><span style="color:#0000ff; font-weight:bold; ">function</span> getRandomCity<span style="color:#0000ff; ">(</span><span style="color:#0000ff; ">)</span> <span style="color:#0000ff; ">{</span>
<span style="color:#0000ff; font-weight:bold; ">return</span> City<span style="color:#0000ff; ">.</span>count<span style="color:#0000ff; ">(</span><span style="color:#0000ff; ">)</span><span style="color:#0000ff; ">.</span><span style="color:#0000ff; font-weight:bold; ">exec</span><span style="color:#0000ff; ">(</span><span style="color:#0000ff; ">)</span>
<span style="color:#0000ff; ">.</span>then<span style="color:#0000ff; ">(</span><span style="color:#0000ff; ">(</span>count<span style="color:#0000ff; ">)</span> <span style="color:#0000ff; ">=</span><span style="color:#0000ff; ">&gt;</span> <span style="color:#0000ff; ">{</span>
<span style="color:#0000ff; font-weight:bold; ">const</span> <span style="color:#0000ff; font-weight:bold; ">random</span> <span style="color:#0000ff; ">=</span> <span style="color:#800080; font-weight:bold; ">Math</span><span style="color:#0000ff; ">.</span><span style="color:#0000ff; font-weight:bold; ">floor</span><span style="color:#0000ff; ">(</span><span style="color:#800080; font-weight:bold; ">Math</span><span style="color:#0000ff; ">.</span><span style="color:#0000ff; font-weight:bold; ">random</span><span style="color:#0000ff; ">(</span><span style="color:#0000ff; ">)</span> <span style="color:#0000ff; ">*</span> count<span style="color:#0000ff; ">)</span><span style="color:#0000ff; ">;</span>
<span style="color:#0000ff; font-weight:bold; ">return</span> City
<span style="color:#0000ff; ">.</span>findOne<span style="color:#0000ff; ">(</span><span style="color:#0000ff; ">)</span><span style="color:#0000ff; ">.</span>skip<span style="color:#0000ff; ">(</span><span style="color:#0000ff; font-weight:bold; ">random</span><span style="color:#0000ff; ">)</span><span style="color:#0000ff; ">.</span><span style="color:#0000ff; font-weight:bold; ">exec</span><span style="color:#0000ff; ">(</span><span style="color:#0000ff; ">)</span><span style="color:#0000ff; ">;</span>
<span style="color:#0000ff; ">}</span><span style="color:#0000ff; ">)</span><span style="color:#0000ff; ">;</span>
<span style="color:#0000ff; ">}</span>
</pre>