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";
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.