Mozilla-Campus-Club-Cummins / HacktoberFest23_MozillaCCEW

0 stars 0 forks source link

Call Function with Custom Context #102

Open Chaitralikore opened 1 year ago

Chaitralikore commented 1 year ago

Enhance all functions to have the callPolyfill method. The method accepts an object obj as it's first parameter and any number of additional arguments. The obj becomes the this context for the function. The additional arguments are passed to the function (that the callPolyfill method belongs on).

For example if you had the function:

function tax(price, taxRate) { const totalCost = price * (1 + taxRate); console.log(The cost of ${this.item} is ${totalCost}); } Calling this function like tax(10, 0.1) will log "The cost of undefined is 11". This is because the this context was not defined.

However, calling the function like tax.callPolyfill({item: "salad"}, 10, 0.1) will log "The cost of salad is 11". The this context was appropriately set, and the function logged an appropriate output.

Please solve this without using the built-in Function.call method.

akanksha1131 commented 1 year ago

Can you please assign this to me? Akanksha kale , Cummins, TY IT

Chaitralikore commented 1 year ago

@akanksha1131 first you need to fill up the hacktoberfest registration form.

akanksha1131 commented 1 year ago

Yes, I registered right now. Thanks!

On Tue, 17 Oct 2023, 19:32 Chaitralikore, @.***> wrote:

@akanksha1131 https://github.com/akanksha1131 first you need to fill up the hacktoberfest registration form.

— Reply to this email directly, view it on GitHub https://github.com/Mozilla-Campus-Club-Cummins/HacktoberFest23_MozillaCCEW/issues/102#issuecomment-1766484570, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3R6DD6FZ6G5SWRZ55WVLLTX72FV7AVCNFSM6AAAAAA57RVPVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRWGQ4DINJXGA . You are receiving this because you were mentioned.Message ID: <Mozilla-Campus-Club-Cummins/HacktoberFest23_MozillaCCEW/issues/102/1766484570 @github.com>

Chaitralikore commented 1 year ago

@akanksha1131 As you have already been assigned one issue. After completing that you can work on this issue.