How to use the city function from chance

Find comprehensive JavaScript chance.city code examples handpicked from public code repositorys.

49
50
51
52
53
54
55
56
57
58

// address
person.addresses = [{
  preferred: true,
  address1: Chance.address(),
  cityVillage: Chance.city(),
  stateProvince: Chance.province(),
  country: Chance.country({
    full: true,
  }),
fork icon8
star icon16
watch icon5

+ 9 other calls in file

68
69
70
71
72
73
74
75
76
77
    break;
case 'bool':
    s += chance.bool();
    break;
case 'city':
    s += chance.city().toCsv(CSV.delimiter);
    break;
case 'ccnumber':
    s += chance.cc().toCsv(CSV.delimiter);
    break;
fork icon2
star icon8
watch icon0

46
47
48
49
50
51
52
53
54
55
for (let i = 0; i < moviesCount; i++) {
  let title =
    "The " +
    chance.animal() +
    " in " +
    chance.city() +
    " " +
    chance.integer({ min: 1, max: 100 });
  movies.push({
    PK: "MOVIE#" + title.replace(/\W/g, "-"),
fork icon0
star icon2
watch icon0

19
20
21
22
23
24
25
26
27
28
exports.company = function () { return ch.capitalize(ch.word({syllables: 3})) }
exports.email = function () { return ch.email() }
exports.phone = function () { return ch.phone() }
exports.address = function () { return ch.address() }
exports.street = function () { return ch.street() }
exports.city = function () { return ch.city() }
exports.state = function () { return ch.state({full: true}) }
exports.date = function () { return "NOT YET IMPLEMENTED" }

exports.lorem = function (c, type) {
fork icon0
star icon2
watch icon1

+ 3 other calls in file

22
23
24
25
26
27
28
29
30
31


for (var i = 0; i < 10; i++) {
    var city = {
        id: chance.natural({max: 100}),
        name: chance.city() + ', ' + chance.state(),
        streets: []
    }

    for (var j = 0; j < 50; j++) {
fork icon0
star icon1
watch icon18

12
13
14
15
16
17
18
19
20
21
const hour = chance.hour();
const number = chance.natural({ min: 1, max: 15 });
const shortid = require("shortid");
const email = chance.email({ domain: "example.com" });
const address = chance.address({ short_suffix: true });
const city = chance.city();
const state = chance.state({ territories: true, country: "us" });
const zip = chance.zip({ plusfour: true });
const sentence = chance.sentence({ words: 3 });
const word = chance.word({ length: 5 });
fork icon0
star icon0
watch icon0

0
1
2
3
4
5
6
7
8
9
10
11
12
'use strict';


let Chance = new (require('chance'))();


let _getCity = function () {
    return Chance.city();
};


let _getState = function () {
    return Chance.state({ country: 'us', 'full': true });
fork icon0
star icon0
watch icon0

7
8
9
10
11
12
13
14
15
16
    return {
      key: i,
      name: chance.name(),
      age: chance.age(),
      adress: chance.address(),
      city: chance.city(),
      pet: chance.animal(),
    };
  }),
};
fork icon0
star icon0
watch icon0

8
9
10
11
12
13
14
15
16
17
18
19
	return chance.address(options)
}


// city
export function city (options) {
	return chance.city(options)
}


// company
export function company (options) {
fork icon0
star icon0
watch icon0