File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -221,8 +221,24 @@ function initProjectileMotion() {
221221 }
222222
223223 function simulate ( ) {
224- const speed = Math . max ( 1 , Number ( speedInput . value ) || 1 ) ;
225- const angle = Math . min ( 89 , Math . max ( 1 , Number ( angleInput . value ) || 45 ) ) ;
224+ const speed = Number ( speedInput . value ) ;
225+ const angle = Number ( angleInput . value ) ;
226+
227+ // Reset previous states
228+ resultEl . style . color = "" ;
229+
230+ // Comprehensive Validation Check
231+ if ( isNaN ( speed ) || speed < 1 || speed > 200 ) {
232+ resultEl . textContent = "❌ Error: Speed must be between 1 and 200 m/s." ;
233+ resultEl . style . color = "#ef4444" ;
234+ return ;
235+ }
236+
237+ if ( isNaN ( angle ) || angle < 1 || angle > 89 ) {
238+ resultEl . textContent = "❌ Error: Angle must be between 1° and 89°." ;
239+ resultEl . style . color = "#ef4444" ;
240+ return ;
241+ }
226242
227243 const stats = projectileStats ( speed , angle ) ;
228244 const points = trajectoryPoints ( speed , angle ) ;
You can’t perform that action at this time.
0 commit comments