Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I appreciate the assistance. I was able to pass however I had few pointers to improve. Please assist with the below: While you've made an
I appreciate the assistance. I was able to pass however I had few pointers to improve. Please assist with the below:
While you've made an attempt to implement the hideandseek game using closures, there are some areas that need improvement. The showPic function seems to belong to a different game, which doesn't align with the hideandseek concept outlined in the task instructions. It's essential to ensure that your code accurately reflects the requirements to demonstrate a thorough understanding of closures and their application in JavaScript.
To enhance your submission for Task I recommend revisiting the task instructions and focusing on creating a function that effectively hides a location and returns another function to seek that location, thereby showcasing a clear understanding of closures and their use in JavaScript programming.
Create a new JavaScript file in this folder called digitalHideSeek.js
Define a function hide that takes in a string as an argument, representing a
hiding location. This function should store the location in a local variable
hideLocation.
Inside the hide function, define another function seek that returns the
hidden location when called.
The hide function should return the seek function, creating a closure
around hideLocation.
Now, call hide with a string argument describing your hiding spot and
assign the return value which is the seek function to a new variable called
startGame.
Log the result of calling startGame. This should print your hiding location,
demonstrating the concept of a closure.
Try logging hideLocation directly from outside of the hide and seek
functions. Observe the result and explain why you think this happens,
demonstrating your understanding of scope.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started