You can split the username with space and you will get an array of each word like this ['Blake', 'Price']. And you join all strings in an array with an empty string and you will get "BlakePrice"

The code is like this

const username = "Blake Price"
const joinedUsername = username.split(' ').join('')
console.log(joinedUsername)

Answer from Kevin Liao on Stack Overflow
🌐
DEV Community
dev.to › jrcharney › split-and-join-the-dichotomy-of-strings-and-arrays-2hb
Split and Join: The Dichotomy of Strings and Arrays - DEV Community
December 19, 2022 - It might have been written before by someone else, but I'd like to give my own interpretation. Strings and Arrays are like Yin and Yang. You use .split() to split an string into an array. You use .join() to join arrays into strings.
Discussions

javascript - How/Can you join/combine a single string in an array? - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Save this question. Show activity on this post. I am trying to join a single string Blake Price together, so remove the space " " in between the first and last name (BlakePrice). Are you even able to join a single string in an array... More on stackoverflow.com
🌐 stackoverflow.com
Javascript Concatenate Array to String - Stack Overflow
When JavaScript coerces an array to a string, it actually call: .join(',') on the array. So you're actually going to be getting better performance with .join(',') manually as opposed to leaving it up to the interpreter to notice you're coercing the array. More on stackoverflow.com
🌐 stackoverflow.com
javascript - How to join/add strings in an array object - Stack Overflow
You can use .map and .join functionalities too. Here .map will take the values based upon the key-pointName and .join is used to return an array as a string. More on stackoverflow.com
🌐 stackoverflow.com
javaScript Array.join("")
The join() method creates and returns a new string by concatenating all of the elements in an array (or an array-like object), separated by commas or a specified separator string. If the array has only one item, then that item will be · So “creates and returns a new string” says nothing ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
6
0
November 3, 2022
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › join
Array.prototype.join() - JavaScript - MDN Web Docs
The join() method of Array instances returns a new string that is the concatenation of all elements in this array, separated by commas or a specified separator string. If the array has only one item, that item's stringification is returned without using the separator.
🌐
Code.mu
code.mu › en › javascript › manual › array › join
The join method - concatenation of array elements into a string in JavaScript
let arr = [1, 2, 3]; let str = arr.join('-'); console.log(str); ... Let's reverse the characters of a string. To do this, split the string into an array using split using the separator '' (this separator will put each character of the string into individual array element), reverse this array with reverse and then join the reversed array back with join:
🌐
daily.dev
daily.dev › home › blog › webdev › join method javascript: faqs answered
Join Method JavaScript: FAQs Answered | daily.dev
May 25, 2026 - It helps you change a list of things into a single line of text. Here's what to remember: join() makes a string from an array by putting a separator, like a comma, between each part.
🌐
ReqBin
reqbin.com › code › javascript › 98ugueow › javascript-array-join-example
How do I join array elements in JavaScript?
To join JavaScript array elements in a string, you can use the array.join(separator) method.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-array-join-method
JavaScript Array join() Method - GeeksforGeeks
January 16, 2026 - The JavaScript join() method is used to combine all elements of an array into a single string.
Find elsewhere
🌐
Futurestud.io
futurestud.io › tutorials › javascript-join-an-array-of-strings-to-a-single-string-value
JavaScript — Join an Array of Strings to a Single String Value
April 27, 2023 - The join method concatenates all array values using the given separator. The default separator is a comma ',': const tags = ['JavaScript', 'Node.js', 'Strings'] const result = tags.join() // 'JavaScript,Node.js,Strings' const result = tags.join(', ') // 'JavaScript, Node.js, Strings' Another way to create a single string out of an array of string values is to combine the map and join methods.
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript array methods › array.prototype.join()
Learn JavaScript Array join() By Practical Examples
November 7, 2024 - The join() method allows you to concatenate all elements of an array and return a new string.
Top answer
1 of 2
23

When JavaScript coerces an array to a string, it actually call: .join(',') on the array. So you're actually going to be getting better performance with .join(',') manually as opposed to leaving it up to the interpreter to notice you're coercing the array. So: x + ',' + y is the fastest, [x, y].join(',') is the best practice(since it makes it easier to modify the behavior), and [x, y] is a tiny bit slower than manually calling .join and can be unreadable at times, but it's more convenient.

2 of 2
5

the short answer: use array.join.

the long answer:

First off, concatenation isn't faster than using array.join(), it's slower. this is because each time you concatenate you destroy two strings and create a new one.

take the following code:

<script>
function concat(){
var txt = '';
for (var i = 0; i < 1000000; i++){
txt =+ i + ',';
}
}

function arr(ar){
var txt = 'asdf' + ar;
}

ar = [];
for (var i = 0; i < 1000000; i++) {
ar.push(i);
}

concat();

arr(ar);

alert('done!');
</script>

and paste it into an html file. Then profile it. On my machine (core i7EE, 16GB RAM, SSD disks, IE9), arr() takes 0ms and concat() takes 12ms. Keep in mind this is over a million iterations (this same test would be quite different on IE6, concat() would take seconds).

Second, concatenation will take the same as array.join when having only two values. So for your example, from a performance perspective, they're both equivalent. if you take the above code and change the 1000000 to 4, both concat and arr take 0ms to execute. this means the difference for your particular flow is either inexistent or so negligible it doesn't show up in a profile.

Third, modern browsers optimize string concatenation using array.join() anyways, so the discussion is probably moot from a performance point of view.

That leaves us with style. Personally, I wouldn't use the first form because I don't like manually concatenating strings (when you've got 2 vars it's rather straightforward, but what if you have 10 vars? that'll make a really long line of code. And what if you receive an array with n values, in comes a for loop). I wouldn't use the second form either because, as pointed out in another answer, the value is coerced to a string, and that means some implicit transformation is going on. The problem here is the implicit part. I know now arrays are joined with a comma when coerced, but what happens if the spec changes, or some genius decides to change the toString implementation of Array.prototype in your codebase? just for fun run this in jsfiddle:

Array.prototype.toString = function() {
return 'not the expected result!';
}

alert([1, 2]);

Can you guess what the answer will be? (the above code will execute the same kind of conversion for the array as your code. coercion via the toString() method)

if you use array.join(','); you'll be futureproofing your code by stating that 1) your array will be joined regardless of the toString implementation and 2) it will be joined with a comma.

🌐
Stack Abuse
stackabuse.com › how-to-concatenate-strings-in-an-array-in-javascript
How to Concatenate Strings in an Array in JavaScript
May 16, 2023 - The easiest way to append all elements in an array into one is the join() method of the Array class. It joins all the elements into a string with the given optional delimiter.
🌐
Programiz
programiz.com › javascript › library › array › join
Javascript Array join() | Programiz
March 4, 2024 - In this tutorial, we will learn about the JavaScript Array join() method with the help of examples. The join() method returns a new string by concatenating all of the elements in an array, separated by a specified separator.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-create-a-string-by-joining-the-elements-of-an-array-in-javascript
Create a String by Joining the Elements of an Array in JavaScript - GeeksforGeeks
August 31, 2026 - In JavaScript, array elements can ... a loop. join() combines array elements using a specified separator. toString() converts the array into a comma-separated string. A for loop can be used when custom joining logic is required. The join() method combines all elements of an array into a string...
🌐
Board Infinity
boardinfinity.com › blog › array-join-in-javascript
Array Join() in JavaScript | Board Infinity
January 2, 2025 - The use of javascript array join() is to combine all the elements of an array and form a new string out of the array.
🌐
Udemy
blog.udemy.com › home › it & development › web development › javascript array join : how to join multiple elements of an array into a string
JavaScript Array Join : How to Join Multiple Elements of an Array into a String - Udemy Blog
April 14, 2026 - If you want to know more about how to write working JavaScript programs and execute them in your browser, sign up for our introductory JavaScript course. We cover all the basics of the language, include how to write and test your own programs. You can use a different separator than the default comma. You can use an entire word, for example: <!DOCTYPE html> <html> <body> <p>Click the button to join the array elements into a string.</p> <button onclick="exampleFunction()">Try it</button> <p id="abc"></p> <script> function exampleFunction() { var shapes = [“Circle”, “Square”, “Triange”, “Rectangle”]; var comb = document.getElementById("abc"); comb.innerHTML = shapes.join(or); } </script> </body> </html>
🌐
freeCodeCamp
forum.freecodecamp.org › curriculum help
javaScript Array.join("") - Curriculum Help - The freeCodeCamp Forum
November 3, 2022 - The join() method creates and returns a new string by concatenating all of the elements in an array (or an array-like object), separated by commas or a specified separator string.
🌐
CodeSweetly
codesweetly.com › javascript-array-join-method
join() in JS – How to Join Array into String | CodeSweetly
join() creates a new string by using a comma, or a user-defined separator, to join the elements of an array object.