JSFiddle - React, Tailwind, and code Playground

by tonkec palonkec

HTML

<p></p>

JavaScript

function merge (string1, string2) {
   /* let us split both of strings into arrays so we can iterate easier*/ 
  var s1 = string1.split("");
  var s2 = string2.split("");
    /* create new array where we are going to store result of iteration */
  var a = new Array;
    /* lets iterate for as long as i is less than array length */
    /* i is increased by one for as long as i is less than array length */
  for (i= 0; i<s1.length; i++) {
      /* get string in array by its position */
      a.push(s1[i] + s2[i]);
  }
   /* a is now equal to  ["a", "1", "b", "2", "c", "3"] but we need string so we are going to use join method and save it in new variable */
  var x = a.join("");
    /* let us return the result*/
  return x;
}

/* This was pretty easy. But I made it only for 3-character strings. I hope I proved to you that I can code. If you are considering to hire me, please do not hesitate to contact me. */ 

merge("abc", "123") == "a1b2c3";