I have recently joined this community and am new to coding. Unfortunately, I do not have anyone who can assist me with my issue. I have watched numerous YouTube videos in an attempt to solve the problem myself. I am working on looping through the array below using if-then and else statements along with the cardCounter function. My goal is to have each item in the array appear individually on the screen and then disappear one by one. However, when I open it in my browser, the array just appears as lines of text.
Here is the code I am currently using:
<script>
const calm1 = [];
calm1[0]= "Silence is the element in which great things fashion themselves
together. —Thomas Carlyle";
calm1[1]= "Take a deep breathe in and count to 7 seconds ";
calm1[2]= "Take a slow exhale out";
calm1[3]= "Self-care is not selfish. You cannot serve from an empty vessel.– Eleanor Brown";
calm1[4]= "Loneliness is a sign you are in desperate need of yourself.― Rupi Kaur,";
calm1[5]= "do not look for healing at the feet of those who broke you― Rupi Kaur,";
calm1[6]= "if you were born with the weakness to fall you were born with the strength to rise― Rupi Kaur";
calm1[7]= "you kill your future by mourning the past― R.H. Sin";
calm1[8]= "Our backs tell stories no books have the spine to carry― Rupi Kaur";
calm1[9]= "what is stronger than the human heart which shatters over and over and still lives― Rupi Kaur";
calm1[10]= "the world gives you so much pain and here you are making gold out of it- there is nothing purer than that― Rupi Kaur";
calm1[11]= "fall in love with your solitude― Rupi Kaur";
calm1[12]= "You do not just wake up and become the butterfly - Growth is a process.― Rupi Kaur";
document.getElementById("calm").innerHTML = calm1;
var words = document.getElementById('calm');
var text = -1;
function cardCounter () {
text++;
if (text<calm1.length) {
words = calm1[text];
}
else {
words = -1;
clearInterval(intervalTimer);
}
;}
var intervalTimer = setInterval(function(){cardCounter()},5000);
</script>