Contact: aviboots(AT)netvision.net.il
39,895 questions
51,826 answers
573 users
function swap(str, left, right) { let arr = str.split(''); let tmp = arr[left]; arr[left] = arr[right]; arr[right] = tmp; return arr.join(''); } let str = "node.js c c++"; str = swap(str, 1, 6); console.log(str); /* run: nsde.jo c c++ */
function swap(str, left, right) { return str.substring(0, left) + str[right] + str.substring(left + 1, right) + str[left] + str.substring(right + 1); } let str = "node.js c c++"; str = swap(str, 1, 6); console.log(str); /* run: nsde.jo c c++ */