How to show results from this function to HTML? (input in textarea)?

How to show results from this function to HTML? (input in textarea)

function chunkIt(str,chunk) {
  var words = str.split(" ");
  var arr = [];
  for (var i = (chunk - 1); i < words.length; i++) {
    var start = i - (chunk - 1);
    arr.push(words.slice(start, start + chunk));
  return => v.join(" "));

var test = "I love you so much, but Joe said \"he doesn't\"!";

Welcome Ivke.

I have edited your post for readability. Please put your code in backticks. Note: backticks ` are not the same as apostrophes '.

1 Like

Well you need to first have a textarea element to put it in. If you plan on have more than one textarea in the project, then I suggest giving it an id attribute and a value that you will reference in the JavaScript code. Next, you can research how to use the getElementById method to target the textarea. Lastly, you will want to research the textContent or innerText property of elements for how you can assign the result of calling your function to it.

The above directions should get you started. Give it and reply back with your updated Codepen so we can see what you have tried.

1 Like

Thank you very much. I updated code .But do not work