Joining two strings with a comma and space between them
Simply
return str1 + ", " + str2;
If the strings are in an Array, you can use Array.prototype.join
method, like this
var strings = ["a", "b", "c"];
console.log(strings.join(", "));
Output
a, b, c
try this:
function test(str1, str2) {
var res = str2 + ',' + str1;
return res;
}