- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Join Map values into a single string with JavaScript?
You can use the concept of Map(). In JavaScript, map has the key value concept in which key must be unique.
We also need to use the join() method to join Map values. Following is the code −
Example
let queryStringAppendWithURL = new Map(); queryStringAppendWithURL.set("firstParamter", ["name=John", "age=23", "countryName=US"]); queryStringAppendWithURL.set("secondParamter", ["subjectName=JavaScript", "Marks=91"]); let appendValue = Array.from(queryStringAppendWithURL.values()).map(value => value.join('?')).join('?'); console.log("The appended value is="+appendValue);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo78.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo78.js The appended value is=name=John?age=23?countryName=US?subjectName=JavaScript?Marks=91
- Related Articles
- Inserting multiple parameter values into a single column with MySQL?
- Convert JavaScript array iteration result into a single line text string
- JavaScript: Combine highest key values of multiple arrays into a single array
- Coalesce values from different properties into a single array with MongoDB aggregation
- C# program to join words into a string in C#
- How to merge objects into a single object array with JavaScript?
- JavaScript: How to map array values without using "map" method?
- How to join two strings to convert to a single string in Python?
- How to join JavaScript array of string
- Join arrays to form string in JavaScript
- JavaScript function to prepend string into all the values of array?
- JavaScript program to merge two objects into a single object and adds the values for same keys
- Combining multiple images into a single one using JavaScript
- Segregating a string into substrings - JavaScript
- How to convert list elements into a single string in R?

Advertisements