Sollicitatievraag bij Zendesk

Technical Interview: Create a function that inserts a dot (".") between each character of a string. There shouldn't be a dot at the beginning or the end of the string, just in between characters.

Antwoorden op sollicitatievragen

Anoniem

9 jul 2016

Straightforward 1-liner solution using ruby array library: def insertDots(str) if (str != '') str[0] + str.split('')[1..-2].map{|a| a.to_s + '.'}.join('') + str[-1]; end end insertDots('adddots'); Cheers!

1

Anoniem

6 feb 2019

def insert_dots(str) str.chars.join('.') end insert_dots('hello') => "h.e.l.l.o"