This file contains hidden or 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 getNumberOfPermutations(input) { | |
if (!input.length) { | |
return 0; | |
} | |
let { length } = input; | |
let dividend = getFactorial(length); | |
let divisor = 0 |
This file contains hidden or 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
<span class="ball"></span> | |
<span class="ball"></span> | |
<span class="ball"></span> | |
<span class="ball"></span> | |
<span class="ball"></span> | |
.ball { | |
width: 20px; | |
height: 20px; | |
border-radius: 50%; |
This file contains hidden or 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
<style> | |
.box { | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
margin: auto; | |
} | |
.red { | |
width: 300px; |
This file contains hidden or 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
// Write a wrapper around the Web Animations API | |
// takes a HTML element upon creation | |
// constructor exposes the HTML element, a `keyframe` array of keyframe objects and a `config` object | |
// the `keyframe` array has a minimum length of 2 (animation start and end), can't start an animation unless satisfied | |
// each object in the `keyframe` array has a CSS property and value with an optional `offset` property (between 0 - 1, for keyframe %) | |
// the config object specifies duration, easing and iterations |
This file contains hidden or 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 makeIndex() { | |
return Math.random().toString(12).substring(2, 12); | |
} | |
function Awesome() { | |
Object.defineProperty(this, 'index', { | |
writable: false, | |
configurable: false, | |
value: makeIndex() | |
}); |
This file contains hidden or 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
// choose an attribute style | |
const AwesomeComponent = ({ onAwesomeHappening }) => ( | |
<div className={`${styles.awesomeHolder}`}> | |
<span | |
data-mode="awesome-mode" | |
data-tagging="awesome-btn-click" | |
className={`${styles.awesomeBtn}`} | |
onClick={ () => onAwesomeHappening('Awesome!') }> | |
Save | |
</span> |
This file contains hidden or 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
/* without making `counter` a global variable refactor callMe | |
so the recursion it's attempting works correctly | |
and it logs 'Finished' when complete | |
var callMe = function() { | |
const counter = 0; | |
if(counter == '10') { | |
console.log('Finished'); | |
} | |
counter++; |
This file contains hidden or 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
/* Array.prototype.fill | |
Can only modify an array that has a length of at least 1 | |
It changes ALL the values of an array to a single value. | |
Make a betterFill method that fills an empty array | |
And takes a first argument which is the length of the array | |
And a second which is the values to insert | |
The second should be either a single value or an array of values |
This file contains hidden or 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
/* Modify the below to create a new builder constructor pattern | |
Give Video a static property called `make` - an object - that creates the following API: | |
Video.make | |
.setSrc('/videos/video.mpeg') | |
.setTitle('AO Video') | |
.setLoop(true); | |
which returns a new instance of Video |
This file contains hidden or 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
/* Create a Stack constructor that | |
- creates an object that stores strings within a single string | |
- that has a way of delimiting strings | |
- has a push, pop, concat method that works exactly like their array counterparts | |
- has an indexesOf method that behaves just like Array.prototype.indexOf but will also find all indexes if more than one exist | |
- does your constructor initialise with a single string or an array of strings? | |
- does it have to be called as a constructor / class - could it just be an object / function? | |
*/ |
NewerOlder