Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

My solution of Rollercoaster

62 views
Skip to first unread message

David Cheung

unread,
Nov 25, 2022, 12:01:30 PM11/25/22
to Intro to JavaScript
var text = 'Hello World!';
var div = document.getElementById('rollercoaster');
for (var i=0; i < text.length; i++) {
  var span = document.createElement('span');
  if (i < ( (text.length - 1) / 2)) {
    span.style = "font-size:" + (10 + (5 * i)) + "px;";
  } else {
    span.style = "font-size:" + (10 + (5 * ( (text.length - 1) - i))) + "px;";
  }
  span.appendChild(document.createTextNode(text[i]));
  div.appendChild(span);
}

Reply all
Reply to author
Forward
0 new messages