Skip to content

Instantly share code, notes, and snippets.

@javascriptacademy-stash
javascriptacademy-stash / isMagic.js
Last active September 24, 2020 11:30
Decide if a number is a magic number in javascript
const isMagic = (num) => {
if (num === 1){
return true;
} else if (num.toString().length === 1){
return false;
}
const numArr = num.toString().split('');
const digitSum = numArr.reduce((acc, currentValue) => {
return parseInt(acc) + parseInt(currentValue);
});
@javascriptacademy-stash
javascriptacademy-stash / style.css
Created October 11, 2021 13:13
Styles for the Matrix effect
html {
background: black;
height: 100%;
overflow: hidden;
}
body {
margin: 0;
padding: 0;
height: 100%;
@javascriptacademy-stash
javascriptacademy-stash / draw.js
Last active October 11, 2021 15:11
matrix draw function
const draw = () => {
context.fillStyle = 'rgba(0, 0, 0, 0.05)';
context.fillRect(0, 0, canvas.width, canvas.height);
context.fillStyle = '#0F0';
context.font = fontSize + 'px monospace';
for(let i = 0; i < rainDrops.length; i++)
{
const text = alphabet.charAt(Math.floor(Math.random() * alphabet.length));
@javascriptacademy-stash
javascriptacademy-stash / index.html
Created October 11, 2021 15:11
HTML file for the raining code effect
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./styles.css">
<title>Matrix digital rain</title>
</head>
<body>
<canvas id="Matrix"></canvas>
@javascriptacademy-stash
javascriptacademy-stash / draw.js
Created October 11, 2021 15:17
matrix draw js
const draw = () => {
context.fillStyle = 'rgba(0, 0, 0, 0.05)';
context.fillRect(0, 0, canvas.width, canvas.height);
context.fillStyle = '#0F0';
context.font = fontSize + 'px monospace';
for(let i = 0; i < rainDrops.length; i++)
{
const text = alphabet.charAt(Math.floor(Math.random() * alphabet.length));