Skip to content

Instantly share code, notes, and snippets.

View danielistyo's full-sized avatar

daniel listyo emanuel danielistyo

View GitHub Profile
@danielistyo
danielistyo / tornado-generator.js
Last active July 19, 2021 16:38
Tornado Generator. This code will create tornado using array 2D. It starts from top left and writes from 1 to right, 2 to down, 3 to left, 4 to up, so on.
function generateTornado(w, h) {
// initiate tornado
const tornado = new Array(h);
for (let i = 0; i < tornado.length; i++) {
tornado[i] = new Array(w);
}
let x = 0,
y = 0,
direction = 'right',