The purpose of this server is to help you learn about all things code, programming, and web development as well as connect with others that are doing the same.
The current admins are:
- Dave Gray (owner)
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Output Element</title> | |
</head> | |
<body> |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>My Page</title> | |
<link rel="stylesheet" href="css/js_chapter_22_css.css" /> | |
<script defer src="js/main.js"></script> | |
</head> |
* { | |
margin: 0; | |
padding: 0; | |
-webkit-box-sizing: border-box; | |
box-sizing: border-box; | |
} | |
html { | |
font-family: Arial, Helvetica, sans-serif; | |
font-size: 16px; |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>My Page</title> | |
<style> | |
* { | |
margin: 0; | |
padding: 0; |
// A memoize decorator function | |
// that is capable of handling multiple parameters | |
export const memoize = (fn) => { | |
const cache = {}; | |
return (...args) => { | |
if (JSON.stringify(args) in cache) { | |
// if you want to verify result comes from cache | |
console.log(cache); | |
return cache[JSON.stringify(args)]; |
// Class with methods | |
class Pizza { | |
constructor(size, crust, sauce) { | |
this.size = size; | |
this.crust = crust; | |
this.sauce = sauce; | |
this.toppings = []; | |
} | |
prepare() { console.log('Preparing...') } | |
bake() { console.log('Baking...') } |
// Our basic function | |
let rectangleArea = (length, width) => { | |
return length * width; | |
} | |
// A decorator that counts the parameters | |
const countParams = (fn) => { | |
return (...params) => { | |
console.log('countParams') | |
if (params.length !== fn.length) { |
// Define methods first. They can be used when building any object. | |
const readyToGo = () => { | |
return { | |
readyToGo() { console.log('Ready to go!') } | |
} | |
} | |
const wheelie = () => { | |
return { |
// Youtube tutorial here: https://youtu.be/LDgPTw6tePk | |
// These functions are designed to be exported, but you could create a class instead. See tutorial video. | |
// #1 proper case | |
export const properCase = (string) => { | |
return `${string[0].toUpperCase()}${string.slice(1).toLowerCase()}`; | |
}; |