0

I have a table Message that contain:

 "message": [
    "New Message of the day",
    "Message 1",
    "Message 2"
  ]

I displayed it's result in the interface of my project, the displaying of the result is like this:

New Message of the day, Message 1, Message 2

How can I replace the , by a ## by a small function ?

Thank you

1
  • We would really need to see the code that does the displaying to know exactly what needs changing, would it be possible to add that? Commented Aug 27, 2019 at 15:53

2 Answers 2

1

You are looking for https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join.

var obj = {
  "message": [
    "New Message of the day",
    "Message 1",
    "Message 2"
  ]
};

console.log(obj.message.join("##"));

Sign up to request clarification or add additional context in comments.

Comments

0
 let messages= [
    "New Message of the day",
    "Message 1",
    "Message 2"
  ]

console.log(messages.join('##'))

3 Comments

This is identical to the existing answer.
Same time maybe we posted
You can use array.map

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.