Pattern Program in JavaScript