3.5 Years Experienced Best Javascript Interview | Chakde Frontend Interview EP - 02

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 พ.ย. 2024

ความคิดเห็น • 146

  • @himanshukhosla
    @himanshukhosla 6 หลายเดือนก่อน +35

    Thank you very much for inviting me for this mock interview round chirag sir. Really loved the thrill of mock interview of Microsoft 😀

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน +3

      Always welcome! Thanks for coming ❤️

    • @riyasahamedm4747
      @riyasahamedm4747 6 หลายเดือนก่อน +1

      can you pls share the link where you refer at 28:40

    • @truth_660
      @truth_660 3 หลายเดือนก่อน

      ​@@engineerchirag kab tak scripted video daal kar logo ko bewkuf banyega

  • @rikki7663
    @rikki7663 5 หลายเดือนก่อน +11

    day 51 of asking: from where we can prepare these types of questions... question quality is superb

  • @anandagar2k
    @anandagar2k 6 หลายเดือนก่อน +8

    For the first problem we can define all these methods in the prototype object, declaring inside calculator will create copy of these methods in each object which is over burden to maintain.
    function compute(){
    this.amount=0;
    }
    compute.prototype.lacs = function(val){
    this.amount = this.amount+val;
    return this;
    }
    compute.prototype.value = function(){
    return this.amount;
    };

  • @deepakchandani5237
    @deepakchandani5237 4 หลายเดือนก่อน +3

    I like this because it is raw & genuine (just like real interviews)
    (Nowadays, it's rare to find genuine conversations on YT 🙂)
    it is informative & learned a few things. Thanks to both of you for taking out time.

  • @VikashKumar-tg3ot
    @VikashKumar-tg3ot 4 หลายเดือนก่อน +1

    I love chirag sir feedback, sir is very humble , he insures no one loss his confidence.

  • @Mr.Zeus11
    @Mr.Zeus11 6 หลายเดือนก่อน +2

    Question 2: FYI those who couldn't get why maximum call stack size exceeded
    In order to access the state.value it has to call "get()" function again => inside get function it's returning "state.value" so basically it's creating N number of "execution context", Each invocation adds a new execution context continues indefinitely.
    Start
    |
    v
    Access state.value
    |
    v
    Invoke getter function
    |
    v
    Return state.value
    |
    v
    Access state.value (again)
    |
    v
    Invoke getter function (again)
    |
    v
    Return state.value (again)
    |
    v
    Access state.value (yet again)
    | |
    | | (This loop continues indefinitely)
    | |
    v v

  • @sumitkumardey3268
    @sumitkumardey3268 6 หลายเดือนก่อน +5

    @chirag once again it's tricky , unique and knowledgeable questions from your side. Thanks , Please keep posting.

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      Thank you, I will. Keep watching, keep sharing ❤️

  • @madhanrock5390
    @madhanrock5390 6 หลายเดือนก่อน +3

    Good interview Again, Learning new things ✌
    Thanks Chirag for investing your time in conducting mock interviews, Immensely helpful ❤

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      My pleasure 🙏❤️

  • @SCRIPTSAG
    @SCRIPTSAG 6 หลายเดือนก่อน +4

    First probkme based on currying second in this and third was related to getter setter great 👍

  • @smrutisagarpattanaik1506
    @smrutisagarpattanaik1506 6 หลายเดือนก่อน +8

    For the first problem, one can use recursion and closure to write a solution like below:-
    function computeAmount(value, total = 0) {
    if (value) {
    total = total + value;
    }
    return {
    lacs: function (value) {
    return computeAmount(value * 100000, total);
    },
    crore: function (value) {
    return computeAmount(value * 10000000, total);
    },
    thousand: function (value) {
    return computeAmount(value * 1000, total);
    },
    value: function () {
    return total;
    }
    }
    }

    • @rishabhmehta6204
      @rishabhmehta6204 5 หลายเดือนก่อน

      but issue is you are passing parameter in actual question we are required not pass any args to computeAmount.

    • @smrutisagarpattanaik1506
      @smrutisagarpattanaik1506 5 หลายเดือนก่อน

      I have mentioned parameters in the function. One does not have to pass argument.That is why null/undefined check is present inside the function. If one runs the function according to the syntax shown in video it should work.

    • @MessiLeo2312
      @MessiLeo2312 5 หลายเดือนก่อน +1

      recursion is not optimized way to solve this problem it will consumed memory stack better go with factory function

    • @smrutisagarpattanaik1506
      @smrutisagarpattanaik1506 5 หลายเดือนก่อน +1

      ​​@@MessiLeo2312 Yes recursion will consume space on call stack. But in the solution it will be one level deep. The reason is I have kept the data and arithmetic calculations in the parent function. But that can also be fixed. Like below solution:-
      function computeAmount() {
      let total = 0;
      let obj = {
      lacs: function (value) {
      total = total + (value * 100000);
      return obj;
      },
      crore: function (value) {
      total = total + value * 10000000;
      return obj;
      },
      thousand: function (value) {
      total = total + value * 1000;
      return obj;
      },
      value: function () {
      return total;
      }
      }
      return obj;
      }
      This will still work.
      JavaScript closure concept is all one needs to solve the problem.

  • @rishabhmehta6204
    @rishabhmehta6204 5 หลายเดือนก่อน

    My Approach for first question
    const calamount={
    val:0,
    lakhs:function(a){
    this.val+=a;
    return this;
    },
    crore:function(a){
    this.val+=a
    return this;
    },
    value:function(){
    return this.val;
    }
    }
    function calculateamount(){
    return calamount
    }
    console.log(calculateamount().lakhs(57).crore(567).lakhs(566).value())

  • @sanketjaiswal76
    @sanketjaiswal76 6 หลายเดือนก่อน +2

    Absolutely one of the great interview i watched , i am learning a Lot from this interviews , whcih will definatly help me in my upcoming interviews.Thanks you so much.

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน +1

      Awesome ❤️. Do share in your network as well. 🙏

  • @VenkatachalamMeyyappan
    @VenkatachalamMeyyappan 21 วันที่ผ่านมา

    ​ @engineerchirag wonderful video series. Just one suggestion. It would be better if you could also share us the solutions. It helps to validate our answers as well since finding the correct solutions for these kind of problems online is not easy.

    • @VenkatachalamMeyyappan
      @VenkatachalamMeyyappan 21 วันที่ผ่านมา

      I guess the main issue on the last problem is the getter and setter share the same name as the attribute. So we cant basically return this.value rather have to change it to return the input value.

  • @RohantaTheDeer77
    @RohantaTheDeer77 หลายเดือนก่อน

    Thank you for such type of content, I love it. I have learnt a lots of new things here. I just have one doubt, Isn't the approach to the first problem is exposing the "amount"? Instead we can wrap all the methods inside an object and return that object reference/object from the "computeAmount" function and each method will also return the reference of the same object except the "value" method which will return the amount only. So this will not expose the "amount" outside of "computeAmount" function directly. Also we don't need to create separate constructor function and create instance. Will it work ?

  • @LearningExperienceAccess
    @LearningExperienceAccess 4 หลายเดือนก่อน

    At 11:00, you don't have to write another function, you can return this object. it will work as expected.

  • @srihariramakrishnan3935
    @srihariramakrishnan3935 6 หลายเดือนก่อน +1

    @engineerchirag I doubt if there is any actual model state.value. Because the getter, setter actually returns and sets input.value. Printing the state value within those methods or anywhere else can help understand it better. I am yet to try this out myself. Intriguing question though! Thanks for it.

  • @chandrasekharmadavaram-nq9dq
    @chandrasekharmadavaram-nq9dq 5 หลายเดือนก่อน

    one the great interview, learnt new things, please keep do more videos

    • @engineerchirag
      @engineerchirag  5 หลายเดือนก่อน

      Thank you! Will do! ❣️

  • @harshitagupta8641
    @harshitagupta8641 5 หลายเดือนก่อน

    Thank you chirag sir for this amazing video ❤.lot of things I have learned from this video.
    Sir Plz keep posting this type of video🙏

    • @engineerchirag
      @engineerchirag  5 หลายเดือนก่อน

      Keep watching ❤️

  • @gunjanvyas695
    @gunjanvyas695 6 หลายเดือนก่อน +1

    Thank you so much!
    Approaching this as if it's my interview, below is my solution
    Q1
    Solution: First approach which came to my mind. (passed!)
    const computeAmount = () => {
    let totalAmount = 0;
    let ans = {
    thousand : (a) => {totalAmount+=a*1000; return ans},
    lacs : (a) => {totalAmount+=a*100000; return ans},
    crore: (a) => {totalAmount+=a*1000000; return ans},
    value:()=> totalAmount
    }
    return ans;
    }
    console.log(computeAmount().lacs(1).lacs(1).thousand(2).value());
    Q2
    Solution: "hello world, Hello" it wrong, need to improve on it on js!
    Q3
    Solution:
    const input = document.createElement("input");
    document.body.appendChild(input);
    const state = { value : "Hi" }
    function onChangeFunc(e){
    console.log("change happened and value is", e.target.value);
    let value = e.target.value;
    state.value = value;
    }
    function model(state, input){
    input.addEventListener("change", (e) => {onChangeFunc(e)} );
    /* need to thing how to add state obj change logic */
    }
    model(state, input);
    console.log(input.value);// Hi
    state.value = "dev"
    console.log(input.value)//dev
    input.value = "engineering chirag"
    input.dispatchEvent(new Event("change"));
    console.log(state.value);
    Have given my raw solutions
    Self Review: Need to improve more on JS this keyword, binding part and keep on improving.
    Thank you Chirag!

  • @大盗江南
    @大盗江南 4 หลายเดือนก่อน

    this is really good one, thank you!

    • @engineerchirag
      @engineerchirag  3 หลายเดือนก่อน

      You're very welcome!

  • @maheshshirate2834
    @maheshshirate2834 6 หลายเดือนก่อน

    As student how is learning web dev,
    I learnt a lot, awesome interview ❤
    Sir, Pls don't stop this seris

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน +1

      Thank you, I will. Keep learning, keep sharing 🚀

  • @prakharomer7745
    @prakharomer7745 6 หลายเดือนก่อน

    It was totally awesome , super tricky questions.

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      Glad you liked it ❤️🙏

  • @sudhanshumarimganti4694
    @sudhanshumarimganti4694 3 หลายเดือนก่อน

    Q1:
    const compute = function () {
    return new (function () {
    this.sum = 0;
    this.lacs = function (val) {
    this.sum = val * 100000;
    return this;
    };
    this.value = function () {
    return this.sum;
    };
    })();
    };
    console.log(compute().lacs(10).value());

  • @sohrabkhan8367
    @sohrabkhan8367 6 หลายเดือนก่อน

    It was very good interview. Questions are very relatable and the approach to solving question is really awesome. Worth to watch the whole video.

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      Keep watching ❤️

  • @FaizanPinjari
    @FaizanPinjari 6 หลายเดือนก่อน +1

    If people thinking what editor it is, it's technical assessment platform codility.

  • @ankushladani496
    @ankushladani496 6 หลายเดือนก่อน

    Thanks Chirag Sir for this awesome series...😊❤

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      Keep watching ❤️

  • @MessiLeo2312
    @MessiLeo2312 5 หลายเดือนก่อน +1

    my answer for 1st problem using factory function
    const createComputeFunctions=()=>{
    let totalAmount=0
    return {
    thousand:function(amount){
    totalAmount+=amount*1000
    return this
    },
    lacs:function(amount){
    totalAmount+=amount*100000
    return this
    },
    crore:function(amount){
    totalAmount+=amount*10000000
    return this
    },
    value:function(){
    return totalAmount
    }
    }
    }
    const compute =createComputeFunctions()
    const result=compute.lacs(15).crore(5).crore(2).lacs(20).thousand(45).crore(7).value();
    console.log(result)

  • @4444-c4s
    @4444-c4s 6 หลายเดือนก่อน +1

    In major frontend interviews these Expectations and Competencies are checked:
    1. Code quality (modular and readable).
    2. Working Code (separation of concerns, production ready code).
    3. Code should easily accommodate new requirements with minimal changes.
    4. Core business Logic.
    5. Low Level Design (Extensibility).
    Sirf Code likha aur ek Acha Scalable Code likhne me jameen asmaan ka fark hota hai...How to write such code. So Please make a detailed video on it bhaiya.

  • @mirage4731
    @mirage4731 3 หลายเดือนก่อน

    For First Question An easy approch -
    function computeAmount(){
    let amount = 0;
    function crore(value){
    amount = amount + (value* 1_00_00_000)
    return this
    }
    function lacs(value){
    amount = amount + (value* 1_00_000)
    return this
    }
    function thousands(value){
    amount = amount + (value* 1_000)
    return this
    }
    function hundreds(value){
    amount = amount + (value* 100)
    return this
    }
    function value(){
    return amount;
    }
    return {crore, lacs, thousands, hundreds, value}
    }

  • @amandubey4412
    @amandubey4412 6 หลายเดือนก่อน

    excellent work

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      Thank you! Cheers! ❤️

  • @arunms6701
    @arunms6701 5 หลายเดือนก่อน

    Ans: 1st Problem
    function computeTheAmount() {
    let totalAmount = 0;
    const operations = {
    lacs(amount) {
    totalAmount += amount * 100000;
    return this
    },
    crore(amount) {
    totalAmount += amount * 10000000;
    return this
    },
    thounsands(amount) {
    totalAmount += amount * 1000;
    return this
    },
    value() {
    return totalAmount
    }
    }
    return operations
    }

  • @sourabhsingh4449
    @sourabhsingh4449 5 หลายเดือนก่อน +1

    No need to do fancy thing in first problem. Returning this will work because instance of function is created when it is called first. I don't know what is the confusion here and it is complicating a simple problem
    function computeAmount() {
    totalAmount = 0;
    this.lacs = function(numLacs) {
    totalAmount += numLacs*100000
    return this;
    }
    this.crore = function(numCrores) {
    totalAmount += numCrores*10000000
    return this;
    }
    this.value = function() {
    return totalAmount;
    }
    return this;
    }
    console.log(computeAmount().lacs(15).crore(2).value());

  • @wickkjohn
    @wickkjohn 6 หลายเดือนก่อน

    Getting excited

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน +1

      Keep watching, keep sharing. Try to attempt questions by yourself 🚀

    • @wickkjohn
      @wickkjohn 6 หลายเดือนก่อน

      @@engineerchirag yes sir I just pause the video and try to solve the problem .

  • @PicardoPlayer
    @PicardoPlayer 6 หลายเดือนก่อน +1

    Just watched half part so far, really an amazing interview.
    I think there some typo, He has 5 years of experience not 3.5 please correct

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      Thanks for highlighting. It will rectified soon!

  • @hkdelhivlogs
    @hkdelhivlogs 16 วันที่ผ่านมา

    Hi @engineerchirag which website he is using in internet for questions no 3 suggestions?

  • @dnyaneshwardongle2210
    @dnyaneshwardongle2210 หลายเดือนก่อน

    Which site you are using for real time asking questions

  •  6 หลายเดือนก่อน

    Question 1 - function computeAmount(){
    let totalAmount =0;
    const returnObj = {
    lacs:function(amount){
    totalAmount+= amount*100000;
    return returnObj
    },
    crore: function(amount){
    totalAmount+= amount*10000000;
    return returnObj;
    },
    thousands: function(amount){
    totalAmount+= amount*1000;
    return returnObj
    },
    value:()=> totalAmount
    }
    return returnObj
    }

  • @BulbDrama
    @BulbDrama 6 หลายเดือนก่อน

    Nice one

  • @anyoneola456
    @anyoneola456 6 หลายเดือนก่อน

    Amazing Mock Interview, best for Self Practice and become familiar to such type of questions, is there any particular website or something where we can practice this questions?
    BTW amazing video, the community needs more such videos.....loved the work and efforts you have put to make this things available on TH-cam. Keep It Up.👍👏

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน +1

      Every Saturday a new video of "Chakde Frontend Interview" will be live - Stay tuned. Keep growing, keep sharing 🚀

  • @nimishgs3259
    @nimishgs3259 5 หลายเดือนก่อน

    First Q:
    function computeAmount () {
    this.value = 0
    const context = {
    lacs: lacs.bind(this),
    crore: crore.bind(this),
    thousands: thousands.bind(this),
    value: value.bind(this)
    }
    function lacs (number){
    const numberInLacs = 100000*number
    this.value += numberInLacs
    return context
    }
    function crore (number){
    const numberInCrores = 10000000*number
    this.value += numberInCrores
    return context
    }
    function thousands (number){
    const numberInThousands = 1000*number
    this.value += numberInThousands
    return context
    }
    function value() {
    return this.value
    }
    return context
    }
    console.log(computeAmount().lacs(15).thousands(20).value())

  • @adityaaditya7286
    @adityaaditya7286 3 หลายเดือนก่อน

    First question he got correct just return this. No need to create other function

  • @manimk9922
    @manimk9922 5 หลายเดือนก่อน

    can you share that link where himanshu referred..?

  • @sameekshagupta9518
    @sameekshagupta9518 6 หลายเดือนก่อน

    Can you also do some React interview questions as well ?

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      Yes, upcoming interview is on ReactJs. Stay tuned 🚀

  • @4444-c4s
    @4444-c4s 6 หลายเดือนก่อน +1

    Please provide codes of all the Questions asked so that we can also try it before watching the solution.

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน +2

      Noted. Thanks for idea 💡

    • @4444-c4s
      @4444-c4s 6 หลายเดือนก่อน

      @@engineerchirag ❤️❤️

  • @pubggamers2325
    @pubggamers2325 หลายเดือนก่อน

    Hello sir i need this type logical question list can you probide a link

  • @mkunboxing
    @mkunboxing 6 หลายเดือนก่อน

    awesome

  • @pravinkumarg8007
    @pravinkumarg8007 4 หลายเดือนก่อน

    state.value inside its own set method triggers the same set method again causing the infinite loops.
    Object.defineProperty(state, 'value', {
    set(newValue) {
    state._value = newValue; // Update internal _value directly
    input.value = state.value // Update input value
    },
    get() {
    return state._value;
    }
    });

  • @salwenikhil456496
    @salwenikhil456496 3 หลายเดือนก่อน

    where we will get source code for this series

  • @namanupadhyay2589
    @namanupadhyay2589 6 หลายเดือนก่อน

    Can we get a separate video for 1 st questions solution

    • @engineerchirag
      @engineerchirag  5 หลายเดือนก่อน

      Noted. Will plan one.

  • @thechallengers6424
    @thechallengers6424 5 หลายเดือนก่อน

    Which real world project have used atleast one of these deep concepts of js???

  • @AbdulMajeed-j6z
    @AbdulMajeed-j6z 6 หลายเดือนก่อน

    in input we already have `change` event listener so why we dispatch again 🤔

  • @arpitgarg6459
    @arpitgarg6459 6 หลายเดือนก่อน

    My solution for first problem:
    function computeAmount(args){
    let total;
    if(!args)
    total = 0
    else{
    total = args
    }
    //console.log('fi', this)
    return {
    thousand: (val) => {
    total = total + val*1000
    return computeAmount(total)
    },
    lacs: (val) => {
    total = total + val*100000
    return computeAmount(total)
    },
    crore: (val) => {
    total = total + val*10000000
    return computeAmount(total)
    },
    value: () => total
    }
    }

  • @nitinakuch4973
    @nitinakuch4973 6 หลายเดือนก่อน

    Where I can practice such JavaScript questions?

  • @karthiksundaram544
    @karthiksundaram544 6 หลายเดือนก่อน

  • @yashsolanki069
    @yashsolanki069 6 หลายเดือนก่อน

    Extremely helpful for all of us.
    Thanks chirag for this series.
    Could you please share, What is the code editor being used here?

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      Thanks Yash for feedback. DM me on LinkedIn for details 😊

  • @surajbhushanpandey2882
    @surajbhushanpandey2882 3 หลายเดือนก่อน

    const calculateAmount = function (initialSum = 0) {
    let sum = initialSum;
    let op = { value: () => sum };
    op.__proto__.lacs = function (lacs = 0) {
    sum += 1_00_000 * lacs;
    return op;
    };
    op.__proto__.crores = function (crores = 0) {
    sum += 100_00_000 * crores;
    return op;
    };
    op.__proto__.thousand = function (thousand = 0) {
    sum += 1000 * thousand;
    return op;
    };
    return op;
    };

  • @abhijeet3844
    @abhijeet3844 6 หลายเดือนก่อน

    I appreciate the efforts. But Nobody uses pure venila javascript now a days. This is just to test the knowledge i guess. But You could have tested in a better way. This is for sure not for 3 years experienced candidate. As it was mock , agreed but real time if you ask most of them will fail to answer. felt bit difficult interview . All the best

  • @DevAditya
    @DevAditya 6 หลายเดือนก่อน

    Which editor is it?

  • @karthiksundaram544
    @karthiksundaram544 6 หลายเดือนก่อน

    Hi chirag what is latest version of javascript

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      ES14 - 2023

    • @karthiksundaram544
      @karthiksundaram544 6 หลายเดือนก่อน

      Hi chirag I guess best version of Java script is es6

  • @gagansuneja7029
    @gagansuneja7029 5 หลายเดือนก่อน

    Does MS take all hiring rounds in a single day only?

    • @engineerchirag
      @engineerchirag  5 หลายเดือนก่อน

      In hiring drives, mostly yes.

  • @mdsalman7707
    @mdsalman7707 6 หลายเดือนก่อน

    Does actual interview also go like this?

    • @shubhanshusahuu
      @shubhanshusahuu 6 หลายเดือนก่อน

      Obviously not

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      Why so? Why did you feel like that?

    • @shubhanshusahuu
      @shubhanshusahuu 6 หลายเดือนก่อน

      @@engineerchirag in actual interview, they don't support or give you hint like you gave

    • @sanketjaiswal76
      @sanketjaiswal76 6 หลายเดือนก่อน +1

      @@shubhanshusahuu it depends if they know u are on right track or not , if u showing them progress then they will help u sometime.

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน +2

      Depends on the interviewer. The intent of the interview is not to reject, but to get the best out of the candidates 😊.
      Sometimes you have to ask for hints and suggestions from the interviewer 😄

  • @trialaccount2244
    @trialaccount2244 6 หลายเดือนก่อน

    From title I thought 3.5 years of experience 🙂

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      Yeah, interview level is 3.5+ experience only. Will get it rectified soon!

  • @mirage4731
    @mirage4731 3 หลายเดือนก่อน

    const element = document.createElement("input")
    const state = {value:"hi"}
    function model(state, input){
    input.addEventListener("change",(e)=>{
    state.value = e.target.value
    })
    Object.defineProperty(state, "value",{
    _temp:"", //using another variable to keep track of data stored in this variable
    set: function(x) {
    element.value = x;
    return this._temp = x;
    },

    get: function() {
    return this._temp;
    },
    })
    }
    model(state, element)
    state.value = "dev"
    console.log("ELEMENT", element.value) // "dev"
    element.value = "engineer"
    element.dispatchEvent(new Event('change'))
    console.log(state.value) // 'engineeringchirag'

  • @niteshs728
    @niteshs728 หลายเดือนก่อน

    Solution for first problem
    function ComputeAmout(){
    let totalAmount=0
    function inner(){
    // return totalAmount
    }
    inner.lacs=function(amount){
    totalAmount+=amount*100000
    return inner
    }
    inner.value= function(){
    return totalAmount
    }

    inner.crore=function(amount){
    totalAmount+=amount*10000000
    return inner
    }
    inner.thousands=function(amount){
    totalAmount+=amount*1000
    return inner
    }
    return inner
    }
    console.log(ComputeAmout().lacs(15).crore(5).crore(2).lacs(15).thousands(45).crore(7).value())

  • @65muralikumarj
    @65muralikumarj 6 หลายเดือนก่อน +2

    This Platform name???

  • @imkir4n
    @imkir4n 6 หลายเดือนก่อน

    which is this online editor?

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      DM me

    • @imkir4n
      @imkir4n 6 หลายเดือนก่อน

      @@engineerchirag how?

    • @engineerchirag
      @engineerchirag  6 หลายเดือนก่อน

      Linkedin

    • @FaizanPinjari
      @FaizanPinjari 6 หลายเดือนก่อน

      Codility

    • @imkir4n
      @imkir4n 6 หลายเดือนก่อน

      @@FaizanPinjari thank you bro

  • @himanshumishra3425
    @himanshumishra3425 6 หลายเดือนก่อน

    function compute(){
    return {
    amount:0,
    lacs:function (params){
    this.amount += params * 100000;
    return this;
    },
    crore: function (params){
    this.amount += params * 10000000;
    return this;
    },
    thousand :function (params){
    this.amount += params * 1000;
    return this
    },

    value : function (){
    return this.amount;
    }
    };
    }
    is this approach wrong ?

  • @views-re2om
    @views-re2om 3 หลายเดือนก่อน

    i am pissing my pants 😂

  • @himanshuraj4766
    @himanshuraj4766 4 หลายเดือนก่อน

    He looks like Badshah 😅

  • @rishabhchopra883
    @rishabhchopra883 4 หลายเดือนก่อน

    What about this code
    function compute() {
    this.total = 0;
    function lakhs(val) {
    this.total += val * 1000;
    return this;
    }
    function crore(val) {
    this.total += val * 100000000;
    return this;
    }
    function value() {
    return this.total;
    }
    this.lakhs = lakhs.bind(this);
    this.crore = crore.bind(this);
    this.value = value.bind(this);
    return this;
    }

  • @premmokashe4896
    @premmokashe4896 6 หลายเดือนก่อน

    is this solution correct
    function CompoundAmount(){
    return{
    result:0,
    lacs:function(v){
    this.result+=Number(`${v}00000`)
    return this
    },
    core:function(val){
    this.result+=Number(`${val}0000000`)
    return this
    },
    thousand:function(th){
    this.result+=Number(`${th}000`)
    return this
    },
    values:function(){
    return this.result
    }
    }
    }
    console.log(CompoundAmount().lacs(5).core(1).thousand(1).lacs(2).values())

    • @aqibmalik6313
      @aqibmalik6313 6 หลายเดือนก่อน

      did u run this

  • @nayansinghal23
    @nayansinghal23 5 หลายเดือนก่อน

    QUES 1 :-
    function computeAmount() {
    const amount = {
    totalAmount: 0,
    lacs: function (number) {
    this.totalAmount += number * 100000;
    return this;
    },
    crore: function (number) {
    this.totalAmount += number * 10000000;
    return this;
    },
    thousand: function (number) {
    this.totalAmount += number * 1000;
    return this;
    },
    value: function () {
    return this.totalAmount;
    },
    };
    return amount;
    }
    console.log(computeAmount().lacs(15).crore(5).crore(2).lacs(20).thousand(45).crore(7).value());

  • @shagunpreetsingh7105
    @shagunpreetsingh7105 6 หลายเดือนก่อน

    My Solution to first problem:
    function computeAmount(){
    return {
    inLac: 0,
    inCrore: 0,
    inThousand: 0,
    thousand: function(value) {
    if(value) {
    this.inThousand = this.inThousand + Number(value) * 100000;
    }
    return this;
    },
    lac: function(value) {
    if(value) {
    this.inLac = this.inLac + Number(value) * 100000;
    }
    return this;
    },
    crore: function(value) {
    if(value) {
    this.inCrore = this.inCrore + Number(value) * 10000000;
    }
    return this;
    },
    value: function(){
    return (this.inCrore + this.inLac + this.inThousand).toLocaleString('hi');
    }
    }
    }
    I am not sure why can't we simply return an object like above from computeAmount function how does factory design pattern help here @engineerchirag please help

  • @BibhutiBhushanSaha
    @BibhutiBhushanSaha 2 หลายเดือนก่อน

    Easy solution
    function computeAmount(){
    let amount = 0
    let obj = {
    lacs: function(num){
    amount = amount + (num * 100000);
    return obj
    },
    crore: function(num){
    amount = amount + (num * 10000000);
    return obj
    },
    thousands: function (num){
    amount = amount + (num * 1000);
    return obj
    },
    value: function (){
    return amount;
    }
    }
    return obj;
    }
    console.log(computeAmount().lacs(15).crore(5).crore(2).lacs(20).thousands(45).crore(7).value());

  • @durgeshgupta6647
    @durgeshgupta6647 6 หลายเดือนก่อน

    hi, this is my solution
    function foo(){
    let total=0
    return {
    lacs(num){
    total=total+num*100000
    return this
    },
    crore(num){
    total=total+num*10000000
    return this
    },
    thousand(num){
    total=total+num*1000
    return this
    },
    value(){
    return total
    }
    }
    }
    console.log(foo().lacs(15).crore(5).crore(2).lacs(20).thousand(45).crore(7).value())

  • @AnkitTyagi-co8rs
    @AnkitTyagi-co8rs 6 หลายเดือนก่อน

    class calculate {
    constructor(){
    this.value=0;
    }
    thousand(amount){
    this.value += amount *1000;
    return this;
    }
    lacs(amount){
    this.value +=amount *100000;
    return this;
    }
    crore(amount){
    this.value += amount *10000000;
    return this;
    }
    final(){
    return this.value;
    }
    }
    const computeAmount = new calculate();
    console.log(computeAmount.lacs(15).crore(5).crore(2).lacs(20).thousand(45).crore(7).final())

  • @mayurwankhade7447
    @mayurwankhade7447 6 หลายเดือนก่อน

    My solution to the first question after watching the video till 11.55, without googling
    function computeAmount() {
    return {
    totalAmount: 0,
    crore(crore) {
    this.totalAmount += crore * 10000000;
    return this;
    },
    lacs(lacs) {
    this.totalAmount += lacs * 100000;
    return this;
    },
    thousand(thousand) {
    this.totalAmount += thousand * 1000;
    return this;
    },
    value() {
    return this.totalAmount;
    },
    };
    }
    console.log(
    computeAmount()
    .lacs(15)
    .crore(5)
    .crore(2)
    .lacs(20)
    .thousand(45)
    .crore(7)
    .value()
    );

    • @mayurwankhade7447
      @mayurwankhade7447 6 หลายเดือนก่อน

      Please let me know if it is right approach or not

  • @satishnarayan8614
    @satishnarayan8614 3 หลายเดือนก่อน

    function computeAmount(){
    let obj={};
    obj.value=0;
    obj.lacs=function(amount){
    this.value=this.value+amount*100000;
    return this;
    }
    obj.crore=function(amount){
    this.value=this.value+amount*10000000;
    return this;
    }
    obj.thousand=function(amount){
    this.value=this.value+amount*1000;
    return this;
    }
    obj.valueOf=function(){
    return this.value;
    }
    return obj;
    }
    console.log(computeAmount().lacs(15).crore(1).thousand(10).valueOf())

  • @hassamsaeed4839
    @hassamsaeed4839 6 หลายเดือนก่อน

    A great interview. I itself learned alot of things ❤🫡

  • @childrenWithGod-xn2rb
    @childrenWithGod-xn2rb 5 หลายเดือนก่อน

    obj.helloWorld() ,,,,, we will get => hello world hello in this way also

  • @karthiksundaram544
    @karthiksundaram544 6 หลายเดือนก่อน