How to parse a string from a JavaScript array?

Following is the code to parse a string from a JavaScript array −


 Live Demo

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   .result {
      font-size: 18px;
      font-weight: 500;
      color: rebeccapurple;
<h1>Parse a string from a JavaScript array</h1>
<div class="result"></div>
<button class="Btn">CLICK HERE</button>
<h3>Click the above button to convert the array arr to string</h3>
   let BtnEle = document.querySelector(".Btn");
   let resEle = document.querySelector(".result");
   let arr = ["Cow", "Lion", "Tiger", "Dog", "Cat"];
   BtnEle.addEventListener("click", () => {
      resEle.innerHTML = arr.toString();


The above code will produce the following output −

On clicking the ‘CLICK HERE’ button −