freshwork

by Krishna Ananthi

JavaScript

let res = [];

function recursive(str) {
  if (str.length == 0) return res;
  if (res.length == 0)
    res.push(str.charAt(0));
  else {
    res.push(res[res.length - 1] + "." + str.charAt(0))
  }

  return recursive(str.substring(1, str.length))
}

console.log(recursive("1234567"))