This is my learning on Pascal converted to JavaScript