View factorialFunction.js
function factorial(number) { | |
if (number === 0) { return 1; } | |
return number * factorial(number - 1); | |
} | |
// factorial(0) -> 1 | |
// factorial(1) -> 1 | |
// factorial(2) -> 2 | |
// factorial(3) -> 6 | |
// factorial(4) -> 24 |
View solution.js
// Name and inputs | |
const hacker1 = "Isak"; | |
const hacker2 = prompt("What is the name of the navigator?"); | |
console.log(`The driver's name is ${hacker1}`); | |
console.log(`The navigator's name is ${hacker2}`); | |
// Conditionals | |
if (hacker1.length > hacker2.length) { | |
console.log( |
View MongoDB Cheat Sheet
// use mongoimport to import a data in JSON format into the database | |
$ mongoimport --db pacman --collection enemies --file pacman.json | |
$ mongoimport --db restaurants --collection restaurants --drop --file ~/downloads/primer-dataset.json | |
// Insert one document in the database | |
$ db.enemies.insertOne({ name: 'pacman' }); | |
// can use javascript in MongoDB | |
$ const t = { name: 'Isak' } | |
$ db.enemies.insertOne(t); |
View App.css
body { | |
margin: 0; | |
padding: 0; | |
font-family: monospace; | |
} | |
header { | |
display: block; | |
height: 5vh; | |
overflow: auto; |
View My linux & mac command line Cheat Sheet
// remove a non empty folder | |
$ rm -rf lampp | |
View My Node.js Cheat Sheet
Full documentation: https://docs.npmjs.com/getting-started/ | |
// Listing globally installed NPM packages and version | |
npm list -g --depth=0 | |
// Global packages can be uninstalled with | |
npm uninstall -g <package> | |
ex. npm uninstall -g jshint |
View index.html
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title></title> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link href="style.css" rel="stylesheet"> | |
</head> | |
<body> | |
<h1 id="unique">Unique ID</h1> |