Coverage

100%
12
12
0

/Users/sebastiansandqvist/Documents/Sites & Projects/apps/modules/s-zipcode/index.js

100%
12
12
0
LineHitsSource
11'use strict';
2
31var dump = require('./zip_dump.json');
4
5// ----- get zip codes in state with lat/long info
6// -- @param state {String} shortcode for US state / territory
7// -- @return {Array} of objects (zip codes w/ coordinates in state)
8// ---------------------------------------
91module.exports = function(state) {
10
11 // get zip codes in given state
121 var zipsInState = [];
13
141 for (var i = 0; i < dump.length; i++) {
15
1643191 if (dump[i].state === state) {
17232 zipsInState.push(dump[i]);
18 }
19
20 }
21
22 // format zip codes
231 var formattedZips = [];
24
251 for (var j = 0; j < zipsInState.length; j++) {
26
27232 var current = {
28 latitude: parseFloat(zipsInState[j].latitude),
29 longitude: parseFloat(zipsInState[j].longitude),
30 cityState: zipsInState[j].city + ', ' + zipsInState[j].state,
31 zip: zipsInState[j].zip
32 };
33
34232 formattedZips.push(current);
35
36 }
37
381 return formattedZips;
39
40};