Lesson 22 +10 XP

Fast & Slow with fast()

Fast & Slow with fast()

Earlier we used * to speed patterns up inside strings. There's also a function version.

fast() speeds a pattern up

fast(2) is like writing *2 inside the string. Try different numbers.

slow() slows a pattern down

slow does the opposite:

fast and slow are inverses

  • fast(n) makes the pattern n times faster.
  • slow(n) makes the pattern n times slower.

The example above plays at normal speed - they cancel out!

Use them on any pattern

TL;DR

  • fast(n) speeds a pattern up.
  • slow(n) slows it down.
  • They're inverses: fast(2).slow(2) = original.
  • Function versions of * and /.