Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

My solution to Rollercoaster

93 views
Skip to first unread message

David Davies

unread,
Apr 24, 2021, 12:11:46 PM4/24/21
to Intro to JavaScript
var text = 'Hello World!';
var div = document.getElementById('rollercoaster');
var tSize = 10;
function addSpanText(){
    div.appendChild(document.createElement('span'));
    div.lastChild.appendChild(document.createTextNode(text[i]));
    div.lastChild.style.fontSize = tSize.toString() + 'px';
};



for (i = 0; i < text.length; i++) {
        if (i < (text.length / 2)-1) {
            addSpanText();
            tSize +=5;
        } 
        else {
            addSpanText();
          if (tSize > 10) {
            tSize -=5;
          }
        }
}

Reply all
Reply to author
Forward
0 new messages