JSFiddle - React, Tailwind, and code Playground

Convert variable definitions into object properties.

by Yurii Predborskyi

JavaScript

let s = `const recurring = ['plan', 'super secure starter', 'mobile broadband'];
const data = ['data', 'internet', 'mb', 'gb', 'wifi'];
const voice = ['minute', 'voice', 'call'];
const messaging = ['messag', 'SMS', 'MMS'];
const longDistance = ['international', 'long distance'];
const roaming = ['roaming', 'global'];
const adjustments = ['discount', 'adjust', '%', 'call charges', 'incorrect', 'debit', 'overcharged'];
const other = ['fee', 'contract charges'];
const equipment = ['equipment', 'faulty replacement'];
const taxes = ['taxes'];`;

let r = /(const \w)(.+$)/gm;

let newText = '';

while(result = r.exec(s)) {
	newText += 'is' + result[1].replace('const ', '').toUpperCase();
  newText += result[2].replace(';',',').replace(' =', ':');
  newText += '\n';
}
console.log(newText);