{"id":23107,"date":"2020-09-24T01:45:02","date_gmt":"2020-09-24T08:45:02","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=23107"},"modified":"2020-09-24T01:45:05","modified_gmt":"2020-09-24T08:45:05","slug":"remove-spaces-from-string-javascript","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/","title":{"rendered":"A Guide to Remove Spaces from String in JavaScript"},"content":{"rendered":"\n<p><em>In JavaScript, there are several different ways to filter out whitespace from a string. This article attempts to illustrate ways you can do that with the whitespace characters in your strings by showing you how to do it in five ways:<\/em><br><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><a href=\"https:\/\/docs.google.com\/document\/d\/1xO3bwpHxMshB6BNkGsWFRcyhkbI2Qvcxu08JUSCeL4M\/preview#heading=h.7huc2t9bxmhm\" target=\"_blank\" rel=\"noopener\" rel=\"nofollow\">Using Loops<\/a><\/li><li><a href=\"https:\/\/docs.google.com\/document\/d\/1xO3bwpHxMshB6BNkGsWFRcyhkbI2Qvcxu08JUSCeL4M\/preview#heading=h.8ujulj6g2g1q\" target=\"_blank\" rel=\"noopener\" rel=\"nofollow\">Using An Array Method: Split\/Filter\/Join Methods<\/a><\/li><li><a href=\"https:\/\/docs.google.com\/document\/d\/1xO3bwpHxMshB6BNkGsWFRcyhkbI2Qvcxu08JUSCeL4M\/preview#heading=h.qvitppeynmbo\" target=\"_blank\" rel=\"noopener\" rel=\"nofollow\">Using Array Methods: Split\/Join<\/a><\/li><li><a href=\"https:\/\/docs.google.com\/document\/d\/1xO3bwpHxMshB6BNkGsWFRcyhkbI2Qvcxu08JUSCeL4M\/preview#heading=h.cn5q6fjvttgq\" target=\"_blank\" rel=\"noopener\" rel=\"nofollow\">Using Replace Method<\/a><\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Using Loops<\/h2>\n\n\n\n<p>When we use for loops, we have to declare a new string variable prior to the loop so we can add to it as we go.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n \n&lt;head&gt;\n  &lt;meta charset=&quot;utf-8&quot;&gt;\n  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot;&gt;\n  &lt;style&gt;\n   body {\n     font-family: 'Roboto', Courier, monospace\n   }\n &lt;\/style&gt;\n  &lt;script&gt;\n    const handleSubmit = str =&gt; {\n \/\/loop\n let newStr = &quot;&quot;;\n for(let i = 0; i &lt; str.length; i++) {\n   if(str[i] !== &quot; &quot;) {\n     newStr += str[i];\n   }\n }\n document.getElementById(&quot;demo&quot;).innerHTML = newStr;\n \n}\n  &lt;\/script&gt;\n&lt;\/head&gt;\n \n&lt;body&gt;\n  &lt;h1&gt;Whitespace Filter&lt;\/h1&gt;\n  &lt;input id=&quot;demoString&quot; value=&quot;&quot; type=&quot;text&quot; name=&quot;inputString&quot; placeholder=&quot;I'm a string&quot;\/&gt;\n   &lt;input type=&quot;submit&quot; onclick=&quot;handleSubmit(demoString.value)&quot;\/&gt;\n   &lt;div id=&quot;demo&quot;&gt;&lt;\/div&gt;\n &lt;\/body&gt;\n&lt;\/html&gt;<\/pre><\/div>\n\n\n\n<p>The loop looks at each individual character to see if it\u2019s a whitespace character. If it\u2019s not, it adds it to the newStr variable. To serve our purpose here, we insert it into the Document Object Model (DOM) so we can see it on screen. If you need to use it elsewhere in your code, you would return the newStr variable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using An Array Method: Split\/Filter\/Join Methods<\/h2>\n\n\n\n<p>Closely related to the loop method explained above, the split\/filter method takes a string, splits it into an array and then uses the ES6 method filter that removes whitespace. Here\u2019s how to do it:\u00a0<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n \n&lt;head&gt;\n  &lt;meta charset=&quot;utf-8&quot;&gt;\n  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot;&gt;\n  &lt;style&gt;\n   body {\n     font-family: 'Roboto', Courier, monospace\n   }\n &lt;\/style&gt;\n  &lt;script&gt;\n    const handleSubmit = str =&gt; {\n  \n\/\/split\/Filter\n const splitted = str.split('');\n const filtered = splitted.filter(char =&gt; {\n   return char !== &quot; &quot;;\n })\n let newStr = filtered.join('');\n \n document.getElementById(&quot;demo&quot;).innerHTML = newStr;\n \n}\n  &lt;\/script&gt;\n&lt;\/head&gt;\n \n&lt;body&gt;\n  &lt;h1&gt;Whitespace Filter&lt;\/h1&gt;\n  &lt;input id=&quot;demoString&quot; value=&quot;&quot; type=&quot;text&quot; name=&quot;inputString&quot; placeholder=&quot;I'm a string&quot;\/&gt;\n   &lt;input type=&quot;submit&quot; onclick=&quot;handleSubmit(demoString.value)&quot;\/&gt;\n   &lt;div id=&quot;demo&quot;&gt;&lt;\/div&gt;\n &lt;\/body&gt;\n&lt;\/html&gt;<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Using Array Method: Split\/Join<\/h2>\n\n\n\n<p>In the previous section, we used split, filter and join to remove the spaces from a string. In reality, we only need to use the split and join methods if we use array methods. All we need to do is split on the space and then join each character!<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n \n&lt;head&gt;\n  &lt;meta charset=&quot;utf-8&quot;&gt;\n  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot;&gt;\n  &lt;style&gt;\n   body {\n     font-family: 'Roboto', Courier, monospace\n   }\n &lt;\/style&gt;\n  &lt;script&gt;\n    const handleSubmit = str =&gt; {\n \n \/\/split\/join\n \t const splitted = str.split(' ');\n \n \t let newStr = splitted.join('');\n \n \t document.getElementById(&quot;demo&quot;).innerHTML = newStr;\n \n}\n  &lt;\/script&gt;\n&lt;\/head&gt;\n \n&lt;body&gt;\n  &lt;h1&gt;Whitespace Filter&lt;\/h1&gt;\n  &lt;input id=&quot;demoString&quot; value=&quot;&quot; type=&quot;text&quot; name=&quot;inputString&quot; placeholder=&quot;I'm a string&quot;\/&gt;\n   &lt;input type=&quot;submit&quot; onclick=&quot;handleSubmit(demoString.value)&quot;\/&gt;\n   &lt;div id=&quot;demo&quot;&gt;&lt;\/div&gt;\n &lt;\/body&gt;\n&lt;\/html&gt;<\/pre><\/div>\n\n\n\n<p>What an interesting little shortcut! You can split on a character of your choice to cut that character out of your string completely and then join the array back together on the individual character to get your string.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using Replace Method:<\/h2>\n\n\n\n<p>The replace method is great to use when you want to use RegEx to filter out all of the spaces in your strings. We need to use RegEx here because replace, by definition, replaces the first instance of what it\u2019s looking for. If we have multiple spaces in our string, the replace method will only take out the first space \u2013 unless we use a regular expression for identifying white space.<br><\/p>\n\n\n\n<p>The global flag at the end of the regular expression is what allows us to search and replace for more than one instance.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n \n&lt;head&gt;\n  &lt;meta charset=&quot;utf-8&quot;&gt;\n  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot;&gt;\n  &lt;style&gt;\n   body {\n     font-family: 'Roboto', Courier, monospace\n   }\n &lt;\/style&gt;\n  &lt;script&gt;\n  \tconst handleSubmit = str =&gt; {\n \t\tlet regex = \/\\s+\/g\n \t\tlet newStr = str.replace(&quot; &quot;, &quot;&quot;);\n \n \t\tdocument.getElementById(&quot;demo&quot;).innerHTML = newStr;\n \n}\n  &lt;\/script&gt;\n&lt;\/head&gt;\n \n&lt;body&gt;\n  &lt;h1&gt;Whitespace Filter&lt;\/h1&gt;\n  &lt;input id=&quot;demoString&quot; value=&quot;&quot; type=&quot;text&quot; name=&quot;inputString&quot; placeholder=&quot;I'm a string&quot;\/&gt;\n   &lt;input type=&quot;submit&quot; onclick=&quot;handleSubmit(demoString.value)&quot;\/&gt;\n   &lt;div id=&quot;demo&quot;&gt;&lt;\/div&gt;\n &lt;\/body&gt;\n&lt;\/html&gt;<\/pre><\/div>\n\n\n\n<p>The \\s is a whitespace character and the + indicates we are looking for one or more whitespace characters that are grouped in a row. The g at the end of the expression, as a reminder, indicates we are looking for multiple different groupings of whitespace characters.&nbsp;<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In this article we\u2019ve covered four ways to take out the white space from a storing in JavaScript. We used loops, the filter method, the split\/join methods and regular expressions. Learning how to do these basic things in JavaScript will give you the tools you need to solve even more complex problems in JavaScript as you progress on your journey!<\/p>\n","protected":false},"excerpt":{"rendered":"In JavaScript, there are several different ways to filter out whitespace from a string. This article attempts to illustrate ways you can do that with the whitespace characters in your strings by showing you how to do it in five ways: Using LoopsUsing An Array Method: Split\/Filter\/Join MethodsUsing Array Methods: Split\/JoinUsing Replace Method Using Loops&hellip;","protected":false},"author":77,"featured_media":23108,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11933],"tags":[],"class_list":{"0":"post-23107","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-javascript"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"JavaScript","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":[]},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Remove Spaces From String JavaScript | Career Karma<\/title>\n<meta name=\"description\" content=\"There are several ways to remove spaces from a string in JavaScript. Learn how to tackle it four different ways in this article on Career Karma\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A Guide to Remove Spaces from String in JavaScript\" \/>\n<meta property=\"og:description\" content=\"There are several ways to remove spaces from a string in JavaScript. Learn how to tackle it four different ways in this article on Career Karma\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-09-24T08:45:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-09-24T08:45:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/erik-mclean-E1nRYGo1cwg-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"680\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Christina Kopecky\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Christina Kopecky\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/remove-spaces-from-string-javascript\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/remove-spaces-from-string-javascript\\\/\"},\"author\":{\"name\":\"Christina Kopecky\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/ae0cdc4a5d198690d78482646894074e\"},\"headline\":\"A Guide to Remove Spaces from String in JavaScript\",\"datePublished\":\"2020-09-24T08:45:02+00:00\",\"dateModified\":\"2020-09-24T08:45:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/remove-spaces-from-string-javascript\\\/\"},\"wordCount\":502,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/remove-spaces-from-string-javascript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/erik-mclean-E1nRYGo1cwg-unsplash.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/remove-spaces-from-string-javascript\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/remove-spaces-from-string-javascript\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/remove-spaces-from-string-javascript\\\/\",\"name\":\"Remove Spaces From String JavaScript | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/remove-spaces-from-string-javascript\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/remove-spaces-from-string-javascript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/erik-mclean-E1nRYGo1cwg-unsplash.jpg\",\"datePublished\":\"2020-09-24T08:45:02+00:00\",\"dateModified\":\"2020-09-24T08:45:05+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/ae0cdc4a5d198690d78482646894074e\"},\"description\":\"There are several ways to remove spaces from a string in JavaScript. Learn how to tackle it four different ways in this article on Career Karma\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/remove-spaces-from-string-javascript\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/remove-spaces-from-string-javascript\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/remove-spaces-from-string-javascript\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/erik-mclean-E1nRYGo1cwg-unsplash.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/erik-mclean-E1nRYGo1cwg-unsplash.jpg\",\"width\":1020,\"height\":680,\"caption\":\"Macbook Pro Keyboard\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/remove-spaces-from-string-javascript\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"A Guide to Remove Spaces from String in JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/ae0cdc4a5d198690d78482646894074e\",\"name\":\"Christina Kopecky\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/image-3-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/image-3-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/image-3-150x150.jpg\",\"caption\":\"Christina Kopecky\"},\"description\":\"Christina is an experienced technical writer, covering topics as diverse as Java, SQL, Python, and web development. She earned her Master of Music in flute performance from the University of Kansas and a bachelor's degree in music with minors in French and mass communication from Southeast Missouri State. Prior to joining the Career Karma team in June 2020, Christina was a teaching assistant, team lead, and section lead at Lambda School, where she led student groups, performed code and project reviews, and debugged problems for students. Christina's technical content is featured frequently in publications like Codecademy, Repl.it, and Educative.\",\"sameAs\":[\"http:\\\/\\\/www.linkedin.com\\\/in\\\/cmvnk\"],\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/christina-kopecky\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Remove Spaces From String JavaScript | Career Karma","description":"There are several ways to remove spaces from a string in JavaScript. Learn how to tackle it four different ways in this article on Career Karma","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/","og_locale":"en_US","og_type":"article","og_title":"A Guide to Remove Spaces from String in JavaScript","og_description":"There are several ways to remove spaces from a string in JavaScript. Learn how to tackle it four different ways in this article on Career Karma","og_url":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-09-24T08:45:02+00:00","article_modified_time":"2020-09-24T08:45:05+00:00","og_image":[{"width":1020,"height":680,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/erik-mclean-E1nRYGo1cwg-unsplash.jpg","type":"image\/jpeg"}],"author":"Christina Kopecky","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"Christina Kopecky","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/"},"author":{"name":"Christina Kopecky","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e"},"headline":"A Guide to Remove Spaces from String in JavaScript","datePublished":"2020-09-24T08:45:02+00:00","dateModified":"2020-09-24T08:45:05+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/"},"wordCount":502,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/erik-mclean-E1nRYGo1cwg-unsplash.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/","url":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/","name":"Remove Spaces From String JavaScript | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/erik-mclean-E1nRYGo1cwg-unsplash.jpg","datePublished":"2020-09-24T08:45:02+00:00","dateModified":"2020-09-24T08:45:05+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e"},"description":"There are several ways to remove spaces from a string in JavaScript. Learn how to tackle it four different ways in this article on Career Karma","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/erik-mclean-E1nRYGo1cwg-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/erik-mclean-E1nRYGo1cwg-unsplash.jpg","width":1020,"height":680,"caption":"Macbook Pro Keyboard"},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/remove-spaces-from-string-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/careerkarma.com\/blog\/javascript\/"},{"@type":"ListItem","position":3,"name":"A Guide to Remove Spaces from String in JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e","name":"Christina Kopecky","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","caption":"Christina Kopecky"},"description":"Christina is an experienced technical writer, covering topics as diverse as Java, SQL, Python, and web development. She earned her Master of Music in flute performance from the University of Kansas and a bachelor's degree in music with minors in French and mass communication from Southeast Missouri State. Prior to joining the Career Karma team in June 2020, Christina was a teaching assistant, team lead, and section lead at Lambda School, where she led student groups, performed code and project reviews, and debugged problems for students. Christina's technical content is featured frequently in publications like Codecademy, Repl.it, and Educative.","sameAs":["http:\/\/www.linkedin.com\/in\/cmvnk"],"url":"https:\/\/careerkarma.com\/blog\/author\/christina-kopecky\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/23107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/77"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=23107"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/23107\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/23108"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=23107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=23107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=23107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}