A Pen by Jorge Epuñan on CodePen.
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 encode(strs): | |
encodedStr = "" | |
// Iterate thru strings | |
for each str of strs: | |
// Escape colons in the string | |
escapedStr = str.replace(/:/g, "::") | |
// Append the length of the escaped string to the encodedStr | |
encodedStr += length(escapedStr) + ":" + escapedStr | |
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
console.log(7%3); | |
function fizzBuzz(num) { | |
for (var i = 1; i <= num; i++) { | |
if (i % 15 === 0) console.log("FizzBuzz"); | |
else if (i % 5 === 0) console.log("fizz"); | |
else if (i % 3 === 0) console.log("Buzz"); | |
else console.log(i); | |
} | |
} |
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
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" | |
width="600px" height="100px" viewBox="0 0 600 100"> | |
<style type="text/css"> | |
<![CDATA[ | |
text { | |
filter: url(#filter); | |
fill: white; | |
font-family: 'Share Tech Mono', sans-serif; |
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
// shorter recursive starts at 1 | |
function fibRecursive(n) { | |
if(n <= 1) return 1; | |
return fibRecursive(n - 2) + fibRecursive(n - 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
// recursive starts at 0 | |
function fib(number) { | |
if(number == 0) return 0; | |
if(number == 1) return 1; | |
return fib(number - 2) + fib(number - 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
// enter a number | |
function fibonacci(num) { | |
var a = 1, b = 0, temp2; | |
while(num > 0) { | |
temp2 = a; | |
a = a + b; | |
b = temp2; | |
num--; | |
console.log(temp2); |
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
// recursive. output starts at 0 | |
function fib(number) { | |
if(number == 0) return 0; | |
if(number == 1) return 1; | |
return fib(number - 2) + fib(number - 1); | |
} | |
// shorter recursive. output starts at 1 | |
function fibRecursive(n) { | |
if(n <= 1) return 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
// for loop | |
function fibFor() { | |
var a = 0, b = 1, i = 1, result; | |
result = b; | |
console.log(a + '\n' + result + '\n'); | |
for(i; i < 10; i++) { | |
console.log(result + '\n'); | |
result = a + b; | |
a = b; | |
b = result; |
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
"use strict"; | |
// below functions can be accessed from the console | |
// very basic fibonacci | |
function basicFib() { | |
var first = 1, | |
second = 0, | |
answer = first + second; | |
while(answer < 100) { |
NewerOlder