Command Palette

Search for a command to run...

Hectal
Phase 9: Animation
3D Web · Exercise 2 of 6 PreviousNext
Beginner

Write a tween by hand

Finish createTween(from, to, duration, ease). Its tick(delta) must add the delta to an elapsed time (never past the duration) and return the eased value.

With easeOutCubic, a tween from 0 to 1 over 1 s must print 0.875 after 0.5 s, and stay at 1.000 at the end and after.

What Check tests

  1. Halfway is 0.875
  2. The end is exactly 1.000
  3. Past the end it stays at 1.000
  4. A tween from 10 to 20 over 2 s is 15.000 at 1 s with linear easing

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.