Implementing hasOwnProperty

//I am trying to write the source code of hasOwnProperty

et k={h:1,b:2}
Object.prototype.hasOwnPropertys=function(property){

let value=-1
for( let i in this){
if(property===i){
return true


}
}

return false
}

let b=k.hasOwnPropertys("h")
console.log(b)
// result true
b=k.hasOwnPropertys("h8")
console.log(b)

Check it is correct or not

when you have a question not related to the current topic please create a new thread
this time I will create the thread for you, next time please do it yourself.

in your loop you have return statements of which one will always execute. in this way the loop will stop at first iteration and never check the rest

you need to change where one of the return statements is

I have posted that code here is not to clarify my doubt. Let them understand what exactly happening inside code

Yes you are right. I have not thought that case
Can you check the code. Now i think it is a working solution

I understood. Thank you