Photo by Sophie Elvis on Unsplash
  1. Bubble Sorting Algorithm:
function bubbleSort2(a) {
for (let i = 0; i < a.length; i++) {
for (let j = 0; j < a.length; j++) {
if (a[j] > a[j + 1]) {
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
return a;
}


Photo by Neil Thomas on Unsplash
Array.prototype.myMap = function (callback) {
const newArray = [];
for(const item of this) {
newArray.push(callback(item));
}
return newArray;
};
Function.prototype.myCall = function(obj) {
obj = obj || global;
var id = "00" + Math.random();
while (obj.hasOwnProperty(id)) {
id = "00" + Math.random();
}
obj[id] = this;
let arg=[];
for(let i=1;i<arguments.length;i++){
arg.push("arguments[" + i + "]");
}
result= eval("obj[id]("+arg+")");
delete obj[id];
return result;
}
Function.prototype.myApply = function(obj, argArr) {
obj = obj || global;
var id = "00" + Math.random();
while (obj.hasOwnProperty(id)) {
id = "00" + Math.random();
}
obj[id] = this;
let arg=[]…




We are going to write test case for reducer which is quite simple compare to action and component test case.From reducer test case file we will pass the dummy data and will test that the initial state object is updating based on data we are passing from test case or not.


Assuming you have reactjs application configured,we are going to define component in react js and will test it using enzyme.

added sample element in render function


We can setup react application using command npm create-react-app

add the redux dependencies in package.json

Gorakh Nath

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store