Показать сообщение отдельно
  #1 (permalink)  
Старый 29.11.2022, 14:22
Новичок на форуме
Отправить личное сообщение для Olegsey :) Посмотреть профиль Найти все сообщения от Olegsey :)
 
Регистрация: 29.11.2022
Сообщений: 1

Вот код который я написал, почему он выводит NaN? Как это исправить?
var experiments = Number.isInteger(prompt("Please enter the number of experiments conducted this year: "));
var cat = Number.isInteger(prompt("Please enter the number of experiments conducted on cats: "));
var rat = Number.isInteger(prompt("Please enter the number of experiments conducted on rats: "));
var frog = Number.isInteger(prompt("Please enter the number of experiments conducted on frogs: "));
 
animals = cat + rat + frog;
 
var catResult = cat / experiments * 100;
var ratResult = rat / experiments * 100;
var frogResult = frog / experiments * 100;
 
if (animals > experiments) {
    confirm("You have not conducted so many experiments, there are too many animals indicated!");
} else if (animals < experiments) {
    confirm("You have conducted more experiments, apparently you forgot about someone, check, the number of animals should coincide with the number of experiments!");
} else {
    confirm(`Experiments on cats amounted to: ${catResult}`);
    confirm(`Experiments on rats amounted to: ${ratResult}`);
    confirm(`Experiments on frogs amounted to: ${frogResult}`);
}
Ответить с цитированием