I have a very few knowledge in JavaScript, so sorry in advance for this question.
I have a method:
function userAgent() {
var result = "";
navigator.userAgentData.getHighEntropyValues(["platformVersion"])
.then(ua => {
if (navigator.userAgentData.platform === "Windows") {
const majorPlatformVersion = parseInt(ua.platformVersion.split('.')[0]);
if (majorPlatformVersion >= 13) {
console.log("Windows 11 or later");
result = "Windows 11 or later";
}
else if (majorPlatformVersion > 0) {
console.log("Windows 10");
result = "Windows 10";
}
else {
console.log("Before Windows 10");
result = "Before Windows 10";
}
}
else {
console.log("Not running on Windows");
result = "Not running on Windows";
}
});
return result;
}
And it returns empty string, but prints to console the correct value.
Please, tell me what is my mistake and how to return value here, I want to use it after.
Thank you!