I am very new here and new to code. I not know anyone who can help me with this and have watched allot of youtube videos on how to try and solve my problem. I am trying to loop through the array below using if then and else statements and the function cardCounter. I want the the items in the array to individually appear on the screen and then disappear one after the other. Right now my array just looks like lines of text on a screen when opened in my browser.
This is my code:
<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 healingat the feet of thosewho 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>