Skip to content

Instantly share code, notes, and snippets.

// Normal function
function isNotEmpty(paper) {
return paper !== "";
}
// Arrow function
const isNotEmpty = (paper) => {
return paper !== "";
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Some Page</title>
</head>
<body>
<nav>
<h1>Chairs</h1>
<ul>
class AddressBook {
constructor() {
this.entries = [];
}
// get all your entries
getAll() {
}
class AcceptedAnswerPrompt {
constructor(acceptedAnswers, ignoreCapitalization) {
this.acceptedAnswers = acceptedAnswers;
this.ignoreCapitalization = ignoreCapitalization;
}
checkIfAccepted(answer) {
// return true if it's in the list, false if it's not
for(const acceptedAnswer of this.acceptedAnswers) {
body {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
/***** Navbar *****/
.navbar {
// The same thing as the other one, I just changed the syntax of the first two lines to ES6 Classes, if that makes it clearer
class List {
countSpecDigits(integersList, digitsList){
// keep a tally of the digits that I see that I'm supposed to count
const tallyList = digitsList.map(number => [number, 0]);
// loop over the list of integers
for(const integer of integersList) {
const integerDigitList = String(integer).split("").map(Number);
for(const digit of integerDigitList) {
class AcceptedAnswerPrompt {
constructor(acceptedAnswers, ignoreCapitalization) {
this.acceptedAnswers = acceptedAnswers;
this.ignoreCapitalization = ignoreCapitalization;
}
checkIfAccepted(answer) {
// return true if it's in the list, false if it's not
for(const acceptedAnswer of this.acceptedAnswers) {
/*
*
*
* This code was written specifically for a CodeWars kata, and is different than the code
* we worked through in class because it is designed for a different purpose.
* It shows that there is not one right way to break things into classes/objects (or functions)
* it depends on what your goals are and what you need it to do!
*
* Also, this isn't doctrine on how to solve this problem,
<!DOCTYPE html>
<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">
<title>Document</title>
</head>
<body>
<script src="week2.js"></script>
<!DOCTYPE html>
<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">
<title>Document</title>
</head>
<body>
<nav>