Guest, before posting your code please take these rules into consideration:
It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
Don't share a wall of code. All we want is the problem area, the code related to your issue.
The answer above me uses Python, not JS. They posted the wrong type of code, but as they said - their answer is very similar to what we can do in JS.
Here's a working example:
Code:
var a = 1234;
var b = 5678;
a = a.toString();
b = b.toString();
var newstr = '';
for(var x = 0; x < a.length; x++){
newstr += a[x];
newstr += b[x];
}
console.log(newstr);
If you want to use the similar style to str() (from Python) instead of .toString() then you can use the JS built in String():
Code:
var a = 1234;
var b = 5678;
a = String(a);
b = String(b);
var newstr = '';
for(var x = 0; x < a.length; x++){
newstr += a[x];
newstr += b[x];
}
console.log(newstr);