Day - 27
Hello, everyone! I am here again to post the 27th day of my coding challenge. I came up with several problems and their solutions. I think we are going well. You know, consistency is the key to success. If you started your own challenges, I would support you as well.
Nowadays, I am trying to solve questions only related to JavaScript on LeetCode to improve my JavaScript skills.
Let's start coding.
/*
* @param {Object} object
* @param {Function} classFunction
* @return {boolean}
*/
var checkIfInstanceOf = function (obj, classFunction) {
if (
obj == null || typeof obj == null ||
typeof classFunction !== "function"
)
return false;
return Object(obj) instanceof classFunction;
};
2. Problem 2619. Array Prototype Last
Array.prototype.last = function ()
let lengthOfArray = this.length;
if (lengthOfArray === 0) return -1;
return this[this.length - 1];
};
3. Problem 2625. Flatten Deeply Nested Array
/*
* @param {any[]} arr
* @param {number} depth
* @return {any[]}
*/
var flat = function (arr, n) {
let res = [];
for (const element of arr) {
if (Array.isArray(element) && n > 0) {
res.push(...flat(element, n - 1));
} else {
res.push(element);
}
}
return res;
};
Ok, it is the end of my post, and thank you for spending your time reading my post. If you like the post, you can share it with your friends.
Hello Abbosbek... We post 100's of job opportunities for developers daily here. Candidates can talk to HRs directly. Feel free to share it with your network. Visit this link - https://jobs.hulkhire.com And start applying.. Will be happy to address your concerns, if any