Skip to content

Instantly share code, notes, and snippets.

View ctodmia's full-sized avatar

Carine Todmia ctodmia

View GitHub Profile
@ctodmia
ctodmia / stringify.js
Last active November 18, 2022 15:30
Reimplementation of JSON.stringify
//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') {
// 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');