Posted in Interesting, Memoirs

Ho Ho Ho ! ЁЯОЕ Memoirs of Merry Christmas ЁЯТл

Growing up in a neighborhood that was with a mix of people with different religions and their respective cultures brings back the vivid memories of today from the past, Christmas and the festivities that follow, the celebrations and preparations by young as well as old.

The kids were always excited about collecting items for Christmas tree, the crib, hut decoration, the list goes on with small statues of baby Jesus Christ, mother Mary, villagers, houses, dried grass, lighting, stars, shining balls, jingle bells and so on. Back then though, things were available readymade in the stores/market, unlike today, people believed in investing time in little things, call it a self-help or being self-reliant and satisfaction of doing their own decorations, however small or big. The afternoons a week before Christmas were spent mostly in the kitchen by women in preparing the sweet specialties with delicacies of mouth melting Dodol, Bebinca, the crispy Rose cookies, Kormolas etc.

Every locality had a group of zealous youngsters who hosted the celebrations which lasted till the new year and was open for public. The main attractions were the big hut with a unique scenery depicting Jesus’ birth and happiness all around, a big Star(bamboo stick make wrapped nicely with clean white cloth) with embossed “Wish you all a Merry Christmas” Christmas tree, big fat white Snow man, and an old man.

Most awaited daily evening game was the Housie(the game of numbers and luck), it could be bought as one ticket for two Rupees and three tickets for five Rupees. This game had two rounds, the first one was called “Jaldi Five”, which was over after calling out five random numbers from a glass jar and the next round went on till they got the winner. The last night that is the 31st December had special visitor Santa Claus, karol singing, games like treasure hunt and musical chair.

Here’s is to wishing all the readers a Merry Christmas! with these memoirs.

Posted in Interesting, Programming, Web Tech

Fun with JS array functions

If you are a JS programmer you must have used arrays quite often. While working with arrays, we somehow always tend to use for loop or Array.forEach() function followed by conditional if-else block checking. To bring into practice the use of already existing prototype array functions we have to understand when to use which functions. So, lets have some fun in understanding and KISS(Keep It Simple, Stupid!). Most of this function are self explanatory from their names itself.

Array.find() method returns the value of first element present in the array that satisfies the testing condition else returns undefined.
var arr = [35, 98, 78, 1, 8, 3];
var findEle = arr.find(function(ele){
return ele > 50;
});
console.log(findEle);

This will return 98 which is the first element that satisfies condition ele > 50.

Array.findIndex() method returns the index of the first element in the array that satisfies the provided testing function else returns -1.
var arr = [35, 98, 78, 1, 8, 3];
var findEleIndex = arr.findIndex(function(ele){
return ele < 10;
});
console.log(findEleIndex);

This will return 3 which is the index of first element that satisfies condition ele < 10.

Array.includes()method determines whether an element is present and returns boolean.
var arr = [35, 98, 78, 1, 8, 3];
var isPresent = arr.includes(98);
console.log(isPresent);

This will return true as 98 is present in the array arr.

Array.some() method determines whether atleast one element of the array satisfies the testing condition and returns boolean.
var arr = [35, 98, 78, 1, 8, 3];
var isPresent = arr.some(function(ele){
return ele > 50;
});
console.log(isPresent);

Array.every() method tests whether every array element passes the test and returns boolean.
var arr = [35, 98, 78, 1, 8, 3];
var test = arr.every(function(ele){
ele > 10;
});
console.log(test);

This will return false as 1 and 3 are less than 10 and test condition fails.

Array.map() creates a new array by applying some action on every element in the original array.
var arr = [35, 98, 78, 1, 8, 3];
var mapValue = arr.map(function(ele){
return ele * 2;
});
console.log(mapValue);

This will return an [70, 196, 156, 2, 16, 6].

Array.forEach() executes action(s) for every elemnt in the array. It is similar to for loop.

Array.filter() creates a new array depending on if the condition is satisfied or not.
var arr = [35, 98, 78, 1, 8, 3];
var mapValue = arr.filter(function(ele){
return ele > 50;
});
console.log(ele);

This returns [98, 78].