function loveCalculator(flower1, flower2) { if (flower1 % 2 === 0 && flower2 % 2 !== 0) { return true; } else if (flower1 % 2 !== 0 && flower2 % 2 === 0) { return true; } else { return false; } }

// 调用函数进行测试 console.log(loveCalculator(3, 4)); // true console.log(loveCalculator(2, 6)); // false console.log(loveCalculator(1, 5)); // true

用javascript实现蒂米和莎拉认为他们相爱了但在他们居住的地方他们只有在各自摘了一朵花后才会知道。如果一朵花的花瓣是偶数而另一朵花的花瓣是奇数那就意味着他们相爱了。写一个函数取每朵花的花瓣数如果它们相爱则返回true如果没有则返回false。

原文地址: https://www.cveoy.top/t/topic/091 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录