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
angular.module('animated-checkmark', []).directive('animatedCheck', animatedCheck); | |
function animatedCheck() { | |
const svgTemplate = ` | |
<div class="checkmark-container"> | |
<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52"> | |
<g> | |
<circle class="checkmark-outline" cx="26" cy="26" r="25" fill="none" /> | |
<circle class="checkmark-circle" cx="26" cy="26" r="25" fill="none" /> | |
<path class="checkmark-check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8" /> | |
</g> |
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
//spec | |
capitalize('my mom is cooking') // My Mom Is Cooking | |
capitalize('wait, I'm coming!') // Wait I'm Coming! | |
//solution 1 | |
function capitalize(str) { | |
const words = []; | |
for(let word of str.split(' ')){ | |
words.push(word[0].toUpperCase() + word.slice(1)) |
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
//specs | |
anagrams('rail safety', 'fairy tales') // true | |
anagrams('RAIL SAFETY', 'fairy tales') // true | |
anagrams('hi there', 'bye there') // false | |
//solution 1 | |
function anagrams(strA, strB) { | |
const charMapA = buildCharMap(strA); | |
const charMapB = buildCharMap(strB); |
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
//specs | |
reverseString('hello world') //dlrow olleh | |
//solution 1 | |
function reverseString(str) { | |
return str.split('').reverse().join('') | |
} | |
//solution 2 | |
function reverseString(str){ |
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
//specs | |
reverseInt(12); //21 | |
reverseInt(500); //5 | |
reverseInt(-15); //-51 | |
function reverseInt(n) { | |
const reversed = n.toString().split('').reverse().join('') | |
return parseInt(reversed) * Math.sign(n) | |
} |
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
//specs | |
const str = 'nice to meet you!'; | |
buildCharMap(str); // {"n":1,"i":1,"c":1,"e":3," ":3,"t":2,"o":2,"m":1,"y":1,"u":1,"!":1} | |
function buildCharMap(str) { | |
const char = {}; | |
for(let character of str) { | |
char[character] = char[character] && char[character] + 1 || 1; | |
} | |
return char; |
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
//specs | |
fizzBuzz(15); | |
1 | |
2 | |
fizz | |
4 | |
buzz | |
fizz | |
7 | |
8 |
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
//specs | |
chunk([1,2,3,4], 2) // [[1,2][3,4]] | |
chunk([1,2,3,4,5], 2) // [[1,2],[3,4],[5]] | |
chunk([1,2,3,4,5], 10) // [[1,2,3,4,5]] | |
//solution 1 | |
function chunk(array, size) { | |
const chunked = []; |
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
steps(4); | |
// | |
# | |
## | |
### | |
#### | |
pyramid(5) | |
// |
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
//specs | |
vowels('Hello World!') //3 | |
vowels('My name is javascript') //6 | |
//solution 1 | |
function vowels(str) { | |
const vowelChar = ['a', 'e', 'i', 'o', 'u']; | |
let count = 0; | |
for (let char of str.toLowerCase()) { |
OlderNewer