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
//The following code is a reimplementation of the native Javascript method JSON.stringify | |
//keep reading for the though process that lead to the solution | |
var stringify = function(obj) { | |
//checks if the input obj is a function statement or undefined | |
if(typeof obj === 'undefined' || typeof obj === 'function') { | |
return undefined; | |
} | |
//checks if the input obj is a string | |
if(typeof obj === 'string') { |
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
// Write a javascript program that displays the numbers from 10 to 100. But for multiples of 4 print "Dr." instead of the | |
// number and for multiples of 6 print "Who". For numbers which are multiples of both 4 and 6 print "Dr. Who" | |
var drWho = function () { | |
for (var i=10; i<=100; i++) { | |
if(i%4 === 0) { | |
console.log('Dr.'); | |
} | |
if(i%6 === 0) { | |
console.log('Who'); |