File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Write a JavaScript program to test whether a string ends with "Script". The string length must be greater than or equal to 6.
2
+
3
+ const prompt = require ( "prompt-sync" ) ( ) ;
4
+
5
+ console . log ( "Enter the String Here : " ) ;
6
+ var str = prompt ( ) ;
7
+
8
+ if ( str . length >= 6 ) {
9
+ var newStr = str . endsWith ( "Script" ) ;
10
+ console . log ( newStr ) ;
11
+ } else {
12
+ console . log ( "Length Must Be Less Than 6!" ) ;
13
+ console . log ( "Not Ends with Script!" ) ;
14
+ }
Original file line number Diff line number Diff line change
1
+ // Write a JavaScript program to display the city name if the string begins with "Los" or "New" otherwise return blank.
2
+
3
+ const prompt = require ( "prompt-sync" ) ( ) ;
4
+
5
+ console . log ( "Enter the City Name : " ) ;
6
+ var city = prompt ( ) ;
7
+
8
+ if ( city . startsWith ( "Los" ) || city . startsWith ( "New" ) ) {
9
+ console . log ( city ) ;
10
+ } else {
11
+ console . log ( "" ) ;
12
+ }
You can’t perform that action at this time.
0 commit comments