2021-01-28

print variable to text area instead of console in javascript

little confused on this. I currently have some variables printing to my console when a button is pressed, but instead I'd like for them to print to a text area (on a single line) instead.

Here's my code

const freq = palindromes.map(palindrome => ({
  palindrome,
  freq: frequency(palindrome)
}));
console.log('all sentences:', sentences);
console.log('only palindromes:', palindromes);
console.log(freq);
<textarea id="output"></textarea>

Which just in the console shows-

[{
  freq: {
   a: 2,
   c: 2,
   e: 1,
   r: 2
},
  palindrome: "racecar"
}]

Instead of this I want it to display like [{freq: { a: 2, c: 2, e: 1,r: 2}, palindrome: "racecar"}] inside the text area I defined in the html. How do I go about accomplishing this?

Thanks!



from Recent Questions - Stack Overflow https://ift.tt/3t0ppfD
https://ift.tt/eA8V8J

No comments:

Post a Comment