# Monthly Archive: September 2015

## Multi dimensional arrays in javascript

Problem description : The following function creates a 2-D array and initialize it with zeros. Find a bug in the code and propse a solution to it. The following gist shows the given code...

## Random Dice Roll Challenge

Problem description : Write a javascript function that accepts a string argument in the format {digit}d{digit}; where The first digit represents the number of dices. The second digit represents the number of sides. The...

## Fizz-Buzz challenge

Problem description : Write a function that prints the numbers from 1 to 100. But for multiples of three prints Fizz instead of the number and for the multiples of five prints Buzz. For...

## Write a function which returns the deep copy of the newly created object.

Input : An Object Output : An Object Logic : Use JSON.stringify() to convert the given object into a string. Use JSON.parse() to convert the given string into a new Object. Solution :

## String compression using the counts of repeated characters.

Input : A string // aaaabbc Output : A string // a4b2c1 Logic : Iterate over the string Compare the current and next characters. If both characters are not same, Then increment the count...

## Reverse a given string, also using similar technique reverse a sentence without reversing words

Reverse a given string Input : A string // ‘Hello’ Output : A string // ‘olleH’ There are many ways of reversing a string. Approach 1 : Simplest way is to use inbuilt javascript...

## Determine if given strings are anagram.

Input : Two strings // ‘dog’, ‘god’ ; ‘foo’,’bar’ Output : Boolean // True ; False Clarifications : Is the comparison of our string permutation case sensitive? Yes Is whitespace significant? Yes Approach 1...

## Determine if a string has all unique characters

Input : A string Output : Boolean Clarifications : Is the input string ASCII or Unicode ? If ASCII then we need storage size of 128 bits Logic : Iterate over entire string If...