Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let low = 0;
- let high = 100;
- let res = Math.floor((low + high) / 2);
- alert('Загадайте число от 0 до 100');
- function start(num) {
- let conf = prompt(`Ваше число больше ${num} ведите < если меньше, > если больше, = если угадал`);
- select(conf)
- }
- start(res)
- function select(conf) {
- switch (conf) {
- case ">":
- low = res;
- break;
- case "<":
- high = res;
- break;
- case '=':
- alert('Угадал');
- return false
- case null:
- return false
- default:
- return start(Math.floor((low + high) / 2))
- }
- res = Math.floor((low + high) / 2);
- start(res)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement