Create function in javascript

I am creating a function for checking MX record in NodeJs.
I am trying to achieve the return value in 0 / 1 but it return error dns is not defined.

I want to achieve the output when I run this code below

if(!mxcheck("xyz@domain.com")) {
   console.log("you have entered an invalid email")
}
exports.mxcheck = async function (email) {
	dns.resolve(email.split("@")[1], "MX", function (err, addresses) {
		if (err) {
			return 1;
		} else if (addresses && addresses.length > 0) {
			return 0;
		}
	});
};

Did you declare the dns?

const dns = require('dns');

:face_with_hand_over_mouth: Ops, I forget…
otherwise, my query is perfect ?