Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

My Solution to Roller Coaster

76 views
Skip to first unread message

Michael Wachsman

unread,
Nov 1, 2021, 11:09:21 AM11/1/21
to Intro to JavaScript
var text = 'Hello World!!';
var div = document.getElementById('rollercoaster');
var textSize = 10, len = text.length;
for(let i = 0; i < len; i++){
  var spanChar = document.createElement('SPAN');
  spanChar.appendChild(document.createTextNode(text.charAt(i)));
  spanChar.style.fontSize = i <= len / 2 ? (textSize + (i * 5)) + "px" : (textSize + ((len - i - 1) * 5)) + "px";
  div.appendChild(spanChar);
}
Reply all
Reply to author
Forward
0 new messages