Day - 27

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.


  1. Problem 2618. Check if the Object Instance of Class

/*
 * @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.


#coding #problems #javascript #algorithms #array #prototype #flat

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

回复

要查看或添加评论,请登录

Abbosbek Sulaymonov的更多文章

  • Hey, how long will this task take?

    Hey, how long will this task take?

    A PM walks up to a developer and asks, "Can you build this feature? When will it be done?" The developer pauses. If…

    2 条评论
  • Polyfills in JavaScript

    Polyfills in JavaScript

    Assalamu alaykum, everyone! I haven't been able to write anything for a long time. I hope you will forgive me for this.

  • Day - 100

    Day - 100

    Assalamu alaykum, everyone! And finally, today is the last day of my 100-day challenge. Getting to this day has not…

    2 条评论
  • Day - 99

    Day - 99

    Assalamu alaykum, everyone! How are you guys? It is the 99th day of my coding challenge! So, I am going to post a good…

    1 条评论
  • Day - 98

    Day - 98

    Assalamu alaykum, everyone! It is time to share the 98th day of my coding challenge! These days, I am solving problems…

  • Day - 97

    Day - 97

    Assalomu alaykum, everyone! It is the 97th day! I am glad to see you here! Today I am going to show a solution for…

    1 条评论
  • Day - 96

    Day - 96

    Assalamu alaykum, everyone! It is the 96th day of my coding challenge! We passed 96 days ). It is a great result! I…

  • Day - 95

    Day - 95

    Assalamu alaykum, everyone! Today, I am going to share the 95th day of my coding challenge! So, let's start the coding!…

  • Day - 94

    Day - 94

    Assalamu alaykum, everyone! It is the 94th day of my coding challenge! I do not know how to describe my thoughts! So…

  • Day - 93

    Day - 93

    Assalomu alaykum, everyone! I am glad to see you here! It is the 93rd day of my coding challenge! So, let's start the…

社区洞察

其他会员也浏览了