Answer the question
In order to leave comments, you need to log in
How to make a setter method in a module?
Good afternoon!
main.js file
const check = require("./test.js")
check("dh39dk")
function checkToken(token) {
if(!arr[token]) return false
return true
}
module.exports = checkToken
const check = require("./test.js")
check.setToken("dh39dk")
check()
Answer the question
In order to leave comments, you need to log in
class TokenValidator {
constructor(token) {
this.token = token
}
check() {
if (!arr[this.token]) return false
return true
}
}
const validator = new TokenValidator("dhejeuus")
console.log(validator.check())
class TokenValidator {
setToken(token) {
this.token = token
}
check() {
if (!arr[this.token]) return false
return true
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question