回答編集履歴
1
OKならtrue、NGならfalseにした
answer
CHANGED
@@ -28,18 +28,18 @@
|
|
28
28
|
const nameAndCondition = citiesName.split(/(OK|NG)/).slice(0, -1);
|
29
29
|
for (let i = 0; i < nameAndCondition.length; i += 2) {
|
30
30
|
const name = nameAndCondition[i];
|
31
|
-
const condition = nameAndCondition[i + 1];
|
31
|
+
const condition = nameAndCondition[i + 1] === 'OK';
|
32
32
|
// もしNGの都市を捨てるならこの行のコメントアウトを削る
|
33
|
-
// if (condition
|
33
|
+
// if (!condition) continue;
|
34
34
|
result[name] = condition;
|
35
35
|
}
|
36
36
|
cityList.push(result);
|
37
37
|
}
|
38
38
|
console.log(cityList);
|
39
39
|
// [
|
40
|
-
// {千代田区:
|
40
|
+
// {千代田区: true, 中央区: true, 港区: true, 新宿区: true, 文京区: false},
|
41
|
-
// {横浜市:
|
41
|
+
// {横浜市: false, 川崎市: true, 横須賀市: true},
|
42
|
-
// {千葉市:
|
42
|
+
// {千葉市: true, 銚子市: false, 市川市: false}
|
43
43
|
// ]
|
44
44
|
```
|
45
45
|
|