JS version of example code in the book Feedback Control