How can I concatenate two or more string values with a space between them?
For example, if I want to concatenate three strings like "Ritik"
, "Dixit"
, and "and"
, the expected output should be "Ritik Dixit and"
. However, what I am getting is "RitikDixitand"
(without spaces).
Can someone provide a solution for this?
1 Like
Hi @Ritik_Dixit
To achieve this functionality, you can create a custom JavaScript function that takes three string parameters and concatenates them with spaces in between. Hereβs an example of how you can write the function:
function concatStrings(str1, str2, str3) {
return str1 + β β + str2 + β β + str3;
}
This function will return the concatenated string with spaces between the input strings, as per your requirement. You can then either directly map the output to an element or store it in a variable for further use.
2 Likes