How to Convert object in arrayObject?

{230: "Abbeville", 231: "Abernant", 232: "Adamsville", 233: "Addison", 234: "Adger", 235: "Akron", 236: "Alabaster", 237: "Alberta", 238: "Albertville", 239: "Alexander City", 240: "Alexandria", 241: "Aliceville", 242: "Allgood", 243: "Alma", 244: "Alpine", 245: "Alton", 246: "Altoona", 247: "Andalusia", 248: "Anderson", 249: "Annemanie", 250: "Anniston", 251: "Arab", 252: "Ardmore", 253: "Ariton", 254: "Arley", 255: "Arlington", 256: "Ashford", 257: "Ashland", 258: "Ashville", 259: "Athens", 260: "Atmore", 261: "Attalla", 262: "Auburn", 263: "Auburn University", 264: "Autaugaville", 265: "Axis", 266: "Baileyton", 267: "Banks", 268: "Bankston", 269: "Bay Minette", 270: "Bayou La Batre", 271: "Bear Creek", 272: "Beatrice", 273: "Beaverton", 274: "Belk", 275: "Bellamy", 276: "Belle Mina", 277: "Bellwood", 278: "Berry", 279: "Bessemer", 280: "Billingsley", 281: "Birmingham", 282: "Birmingham", 283: "Black", 284: "Blountsville", 285: "Boaz", 286: "Boaz", 287: "Boligee", 288: "Bon Air", 289: "Bon Secour", 290: "Booth", 291: "Boykin", 292: "Brantley", 293: "Bremen", 294: "Brent", 295: "Brewton", 296: "Bridgeport", 297: "Brierfield", 298: "Brilliant", 299: "Brooklyn", 300: "Brookside", 301: "Brookwood", 302: "Brownsboro", 303: "Brundidge", 304: "Bryant", 305: "Bucks", 306: "Buhl", 307: "Burnt Corn", 308: "Burnwell", 309: "Butler", 310: "Bynum", 311: "Calera", 312: "Calvert", 313: "Camden", 314: "Camp Hill", 315: "Campbell", 316: "Capshaw", 317: "Carbon Hill", 318: "Cardiff", 319: "Carlton", 320: "Carrollton", 321: "Castleberry", 322: "Catherine", 323: "Cecil", 324: "Cedar Bluff", 325: "Centre", 326: "Centreville", 327: "Chancellor", 328: "Chapman", 329: "Chatom"}


var option = [{text:'Adak', value:1},{text:'Akiachak', value:2},{text:'Akiak', value:3},{text:'Akutan', value:4},{text:'Alakanuk', value:5}, ...];
March 12th 20 at 08:05
1 answer
March 12th 20 at 08:07
var arrayObject = Object.keys(x).reduce(function (acc, curr, i) {
const obj = {
text: x[curr],
value: curr
}
acc.push(obj)

return acc;

}, [])

Find more questions by tags JavaScript