This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function shouter(whatToShout) { | |
return whatToShout.toUpperCase() + '!!!'; | |
} | |
// tests | |
function testShouter() { | |
var whatToShout = 'fee figh foe fum'; | |
var expected = 'FEE FIGH FOE FUM!!!'; | |
if (shouter(whatToShout) === expected) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wisePerson(wiseType, whatToSay) { | |
return 'A wise ' + wiseType + ' once said: "' + whatToSay + '".'; | |
} | |
wisePerson('goat', 'hello world'); | |
// tests | |
function testWisePerson() { | |
var wiseType = 'goat'; | |
var whatToSay = 'hello world'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function textNormalizer(text) { | |
return text.toLowerCase().trim(); | |
} | |
// tests | |
function testTextNormalizer() { | |
var text = " let's GO SURFING NOW everyone is learning how "; | |
var expected = "let's go surfing now everyone is learning how"; | |
if (textNormalizer(text) === expected) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function typoCorrector(sourceText, target, value) { | |
// var matchPattern = target.match(/[A-Za-z]/g); | |
var matchPattern = new RegExp(target, 'g'); | |
var matchCount = (sourceText.match(matchPattern) || []).length; | |
console.log( | |
"Replacing " + matchCount + " instances of " + target + " with " + value); | |
return sourceText.replace(matchPattern, value); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// =================== Square Area =================== // | |
// Create a function called computeArea that takes two arguments: width and height. | |
// It returns the area of a square whose width is width and height is height. | |
// So computeArea(2, 2) would return 4, and computeArea(3, 5) would return 15. | |
function computeArea(width, height) { | |
return width * height; | |
} | |
// tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ======= Traffic Lights ======= | |
* You need to modify and update the | |
* JSBin below, so that when users | |
* click on the button, a randomly | |
* chosen traffic light turns on. | |
*/ | |
function doTrafficLights() { | |
var activeLight = getActiveLight(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q: Why are global variables avoided? | |
A: Because their values can be overwritten by the values of local variables. | |
Local scope (function scope) can have access to global scope. | |
Sometimes this can be useful like when we want global access to a library | |
like JQuery in all our files. Or we want a function to have access in a database. | |
Q: Explain JavaScript's strict mode | |
A: When 'strict mode' is enabled declaring a variable without the var keyword, will rise an error. | |
The 'use strict' command can be put at the top of a file to enforce strict mode for the entire file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ======= max and min (without sort) ======= */ | |
/* | |
To complete this drill, you need to implement two functions, max and min. | |
Both functions should take a single argument: a list of numbers called numbers. | |
max(myNumbers) should return the largest number in the list, while min(myNumbers) | |
should return the smallest. | |
Assume that the numbers input only contains numbers (that is, you don't have to | |
inspect your inputs to confirm they only contain numbers). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ========= Most frequent word ========= // | |
/* In this drill, you need to implement a function named mostFrequentWord. | |
This function takes a single argument, words. Words is an array of lowercase strings, | |
with punctuation stripped out. | |
*/ | |
function mostFrequentWord(words) { | |
// `words` is an array of strings. | |
// Create an empty object to hold most frequent words. | |
var wordsObj = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# A simple script using Duplicity and pass | |
# for cloud encrypted Backblaze backups | |
# Basic Duplicity syntax examples: | |
# https://www.systutorials.com/docs/linux/man/1-duplicity/ | |
# | |
# 1. duplicity [source language="directory"][/source] file://[destination directory] | |
# |
OlderNewer