How to adjust object?

How to adjust

var allCityJsonOptions = {
 1: "Adak", 
 2: "Akiachak", 
 3: "Akiak", 
 4: "Akutan",
 5: "Alakanuk",
...
 }


in

var option = [{text:'Adak', value:1},{text:'Akiachak', value:2},{text:'Akiak', value:3},{text:'Akutan', value:4},{text:'Alakanuk', value:5}, ...];

$('#pick_up_city').selectize({option});

using foreach ?
March 12th 20 at 08:04
1 answer
March 12th 20 at 08:06
Object.keys(yourObj).map(value => { var text = yourObj[value]; return { text, value } })

If you want using forEach – the logic is the same
so frustrating

0:{text: "Abbeville", value: "230"}
1:{text: "Abernant", value: "231"}
2:{text: "Adamsville", value: "232"}
3:{text: "Addison", value: "233"}


me need

{text: 'Abbeville', value: 230},{text: 'Abernant', value: 231},{text: 'Adamsville', value: 232},{text: 'Addison', value: 233}
- Anne commented on March 12th 20 at 08:09
@Anne, you are a first time or what? Don't know how to console the arrays are displayed? - gisselle commented on March 12th 20 at 08:12

Find more questions by tags JavaScript