Separately, the options work. I can not understand how to file them into a single mechanism. The task is as follows - 1. Create an algorithm for deriving the average of the value of three numbers in the form of a flowchart. All numbers are different. Input: three numbers. Output: average (which is between the other two by value). Block diagram - http://d.pr/i/1kflp

<script> a=+prompt("Введите число:"); b=+prompt("Введите число:"); c=+prompt("Введите число:"); if (a>b) (b<c) var d = b; alert(d); if (a<b) (a>c) var d = a; alert(d); if (c<a) (c>b) var d = c; alert(d); </script> 
 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Вывод среднего числа</title> </head> <body> <script> a=+prompt("Введите число:"); b=+prompt("Введите число:"); c=+prompt("Введите число:"); if (a>b) (b<c) var d = b; alert(d); if (a<b) (a>c) var d = a; alert(d); if (c<a) (c>b) var d = c; alert(d); </script> </body> </html> 

  • missed the logical operator - Grundy
  • and braces - BOPOH
  • and round inattention stand - Qwertiy
  • well curly and not necessary :-) - Grundy
  • @Grundy, always with this code. - Qwertiy

3 answers 3

ES6:

 alert(Array.from({length:3}).map(x => +prompt("Введите число")).sort((a,b) => ab)[1]) 
  • 6 times the program suggests to enter a number and it is necessary that it would suggest to enter 3 numbers and the program would derive an average of these numbers. - Rastefano Tafaray
  • @RastefanoTafaray, no. Which browser? - Qwertiy
  • Google Chrome browser and nothing works in safari at all (( - Rastefano Tafaray
  • @RastefanoTafaray, I wrote, ES6. In chrome 6, promises can not be. And in general, there is already some answer below. - Qwertiy
  <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Вывод среднего числа</title> </head> <body> <script> a=+prompt("Введите число:"); b=+prompt("Введите число:"); c=+prompt("Введите число:"); if ((a>b) && (b<c)) { var d = b; alert(d); } else if ((a<b) && (a>c)) { var d = a; alert(d); } else if( (c<a) && (c>b) ){ var d = c; alert(d); } </script> </body> </html> 
  • Uncaught TypeError: (a > b) is not a function(…) - Grundy
  • look at the first comment to the question - this too should have been done + you got confused with the else branches, this should not work at all - BOPOH
  • this option does not work (((and now I wonder why. - Rastefano Tafaray

 <script> a=parseInt(prompt("a:")); b=parseInt(prompt("b:")); c=parseInt(prompt("c:")); if((b<a && a<c) || (c<a && a<b)) alert(a); if((a<b && b<c) || (c<b && b<a)) alert(b); if((a<c && c<b) || (b<c && c<a)) alert(c); </script> 
 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Вывод среднего числа</title> </head> <body> <script> a=parseInt(prompt("a:")); b=parseInt(prompt("b:")); c=parseInt(prompt("c:")); if((b<a && a<c) || (c<a && a<b)) alert(a); if((a<b && b<c) || (c<b && b<a)) alert(b); if((a<c && c<b) || (b<c && c<a)) alert(c); </script> </body> </html>