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
/* | |
My answer for exercise 'Bean counting' | |
in Eloquent JavaScript Second Edition | |
Chapter 3 Functions | |
*/ | |
function countBs(string) { | |
var str = string.toLowerCase(); | |
var array = str.split(""); |
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
/* | |
My answer for exercise 'Recursion' | |
in Eloquent JavaScript Second Edition | |
Chapter 3 Functions | |
*/ | |
function isEven(num) { | |
if (num % 2 == 0) { | |
return true; |
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
/* | |
My answer for exercise 'Minimum' | |
in Eloquent JavaScript Second Edition | |
Chapter 3 Functions | |
*/ | |
function min(a,b) { | |
x = a - b; | |
if (x > 0) { | |
return b; |
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
/* | |
My answer for exercise 'Chess board' | |
in Eloquent JavaScript Second Edition | |
Chapter 2 Program Structure | |
*/ | |
var oddRow = "# # # #"; | |
var evenRow = " # # # #"; |
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
/* | |
My answer for exercise 'FizzBuzz' | |
in Eloquent JavaScript Second Edition | |
Chapter 2 Program Structure | |
*/ | |
for (var i = 1;i < 101;i++) { | |
var output = " "; | |
if (i % 3 == 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
/* | |
My answer for exercise 'Looping a triangle' | |
in Eloquent JavaScript Second Edition | |
Chapter 2 Program Structure | |
*/ | |
var output = ""; | |
for(var i = 1; i < 8; i++) { | |
console.log(output += "#"); |
NewerOlder