EkaterinaRomankova / Codewars

Codewars
0 stars 0 forks source link

Building Strings From a Has #61

Open EkaterinaRomankova opened 1 year ago

EkaterinaRomankova commented 1 year ago

Complete the solution so that it takes the object (JavaScript/CoffeeScript) or hash (ruby) passed in and generates a human readable string from its key/value pairs.

The format should be "KEY = VALUE". Each key/value pair should be separated by a comma except for the last pair.

Example:

solution({a: 1, b: '2'}) // should return "a = 1,b = 2"

function solution(pairs){ return Object.keys(pairs).map(el => el + " = " + pairs[el]).join(','); }

function solution(pairs){ return Object.entries(pairs) .map(([key, value]) => ${key} = ${value}) .join(','); }