After trying to modify my nested array by using the join
method and adding a line break with \n
, I encountered an issue:
const exampleArray = [["Hello"], ["world"], ["example"]]
.map((el) => el)
.join("\n");
Initially, everything worked as expected and I achieved the desired output:
Hello
world
example
However, when attempting to include this exampleArray
within an object's value, the \n
characters were displayed instead of creating line breaks.
This was my approach:
const theObj = {
value: exampleArray,
};
The resulting output showed:
Object { value: "Hello\nworld\nexample" }
To address this issue and have line breaks in the value
, I need to identify what caused the problem and find a solution.