-
Notifications
You must be signed in to change notification settings - Fork 0
Add files via upload #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Document</title> | ||
| </head> | ||
| <body> | ||
| <script src="lesson1.js"></script> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
|
|
||
|
|
||
| let a = prompt("чтобы вычислить объем куба выберите - 1, параллелипипеда - 2, прямоугольного паралеллипипеда - 3, призмы -4, пирамиды -5") | ||
|
|
||
| if (a == 1) { | ||
| function cube(){ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. объявлять функции не нужно внутри условного ветвления. |
||
| let a = prompt ( "Чтобы узнать объем куба - Введите значение стороны, в см" ); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. всегда используй |
||
| let result = a*a*a; | ||
| return result; | ||
| } | ||
| function pPov() { | ||
| let a = prompt ( "Чтобы узнать площадь куба - Введите значение стороны, в см" ); | ||
| let result = 6*a*a | ||
| return result; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. в это и других функциях ты создаёшь ничего против не имею если так для обучения нагляднее, но умные ide пометят это как ненужный блок кода и преобразуют к |
||
| } | ||
| alert("Объем куба = " + cube() + " площадь поверхности куба =" + pPov()); | ||
| } | ||
|
|
||
| else if (a == 2) { | ||
| function parall() { | ||
| let sOsn = prompt ( "Чтобы узнать объем паралеллипипеда - Введите площадь основания, в см" ); | ||
| let h = prompt ( "Чтобы узнать объем паралеллипипеда - Введите высоту, в см" ); | ||
| let result = sOsn * h; | ||
| return result; | ||
| } | ||
| function sPP() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Понимаю что задание математического характера, но даже в таких случаях старайся создавать читаемые имена переменных и функций |
||
| let sParosn = prompt ( "Чтобы узнать площадь прямоугольного паралеллипипеда - Sосн, в см" ); | ||
| let sOParbok = prompt ( "Чтобы узнать площадь прямоугольного паралеллипипеда - Sбок, в см" ); | ||
| let result = 2*sParosn + sOParbok; | ||
| return result; | ||
| } | ||
| alert("Объем паралеллипипеда =" + parall() + "площадь паралеллипипеда = " + sPP()); | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
| else if(a == 3) { | ||
| function vPR() { | ||
| let aPR = prompt ( "Чтобы узнать объем прямоугольного паралеллипипеда - Введите размер стороны, в см" ); | ||
| let bPR = prompt ( "Чтобы узнать объем прямоугольного паралеллипипеда - Введите размер стороны, в см" ); | ||
| let cPR = prompt ( "Чтобы узнать объем прямоугольного паралеллипипеда - Введите размер стороны, в см" ); | ||
| let result = aPR * bPR * cPR; | ||
| return result; | ||
| } | ||
| function sPP() { | ||
| let m = prompt ( "Чтобы узнать площадь паралеллипипеда - Введите сторону, в см" ); | ||
| let f = prompt ( "Чтобы узнать площадь паралеллипипеда - Введите сторону, в см" ); | ||
| let l = prompt ( "Чтобы узнать площадь паралеллипипеда - Введите сторону, в см" ); | ||
| let result = 2*m*f+2*m*l+2*f*l | ||
| return result; | ||
| } | ||
|
|
||
| alert("Объем прямоугольного параллелипипеда =" + vPR() + " Площадьпрямоугольного паралеллипипеда" + sPP()); | ||
| } | ||
|
|
||
| else if (a == 4) { | ||
| function vPrizm() { | ||
| let sPrizm = prompt ( "Чтобы узнать объем призмы - Введите площадь основания, в см" ); | ||
| let hprizm = prompt ( "Чтобы узнать объем призмы - Введите высоту, в см" ); | ||
| let result = sPrizm * hprizm; | ||
| return result; | ||
| } | ||
| function PrismO() { | ||
| let sPRism = prompt ( "Чтобы узнать площадь призмы - Sосн, в см" ); | ||
| let sprisma = prompt ( "Чтобы узнать призмы - Sбок, в см" ); | ||
| let result = 2*sPRism + sprisma; | ||
| return result; | ||
| } | ||
| alert("Объем призмы =" + vPrizm() + "площадь призмы = " + PrismO()); | ||
| } | ||
| else if(a = 5) { | ||
| function vPiram() { | ||
| let sPiram = prompt ( "Чтобы узнать объем пирамиды - Введите площадь основания, в см" ); | ||
| let hPiram = prompt ( "Чтобы узнать объем пирамиды - Введите высоту, в см" ); | ||
| let result = 1/3 * sPiram * hPiram; | ||
| return result; | ||
| } | ||
| function sPiramidy() { | ||
| let PPiram = prompt ( "Чтобы узнать площадь пирамиды - Введите площадь основания, в см" ); | ||
| let pHPiram = prompt ( "Чтобы узнать площадь пирамиды - Введите высоту, в см" ); | ||
| let result = PPiram+pHPiram; | ||
| return result; | ||
| } | ||
| alert("Объем пирамиды =" + vPiram() + " площадь пирамиды" + sPiramidy()); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Отлично! именно такой подход я и ожидал увидеть 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
стоит использовать более читаемые имена переменных.
это сильно упростить читаемость кода через месяц для тебя и другим программистам.
так же тут использовалось
letя бы предпочёлconstдля неизменяемых переменных