code.ashish.me

Atom feed

Recently added: 02 Count Of Subset Sum, 416 Partition Equal Subset Sum, 01 Subset Sum, 518 Coin Change 2, 983 Minimum Cost For Tickets

045 Enclose In Brackets

/**
 * 
 * Ashish Patel
 * e: ashishsushilPatel@gmail.com
 * w: https://ashish.me
 *
 */

/* 
Given a string, enclose it in round brackets.

Example

For inputString = "abacaba", the output should be encloseInBrackets(inputString) = "(abacaba)".
*/

function encloseInBrackets(value) {
  value = value.split('')
  value.push(')')
  value.unshift('(')
  return value.join('')
}

test('enclose In Brackets', () => {
  expect(encloseInBrackets('abacaba')).toEqual('(abacaba)')
});

Created 2019-12-14T23:11:16+05:18 · Edit