[ 🏠 Home / 📋 About / 📧 Contact / 🏆 WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]

/q/ - Q&A Central

Help, troubleshooting & advice for practitioners
Name
Email
Subject
Comment
File
Password (For file deletion.)

File: 1761685698284.jpg (59.83 KB, 1080x720, img_1761685686117_zqkmg8k4.jpg)

1585d No.744

Hey there, friends! Ever wondered how we can keep tabs on an object's method in our code? Well, let's make it happen! Today, I'd like to share a cool coding challenge I came across. We're going to create our own version of the `jest.spyOn` function Here's a boilerplate for you: ```javascript function spyOn(obj, methodName) { // your code here } ``` This Jest function wraps an existing method on an object and logs details like how many times it's called, the arguments it receives, and what it returns. If the object doesn't exist or its property isn't a function, it stops right there So, let's put on our detective hats and dive into this fun little challenge! Once you've built your spyOn function, feel free to share it here or ask for help if you get stuck. Let's learn together! PS: I'm curious - which part of this challenge excites you the most? Are you more into debugging, or do you enjoy finding creative ways to track method calls?

Source: https://dev.to/tomivan/coding-challenge-practice-question-39-44og


[Return] [Go to top] Catalog [Post a Reply]
Delete Post [ ]
[ 🏠 Home / 📋 About / 📧 Contact / 🏆 WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]
. "http://www.w3.org/TR/html4/strict.dtd">