Skip to content

Commit 97e14c1

Browse files
author
Devendra Parmar
committed
Solve two questions of the JavaScript
1. Check the string ends with Script or not 2. Print the name of the city if city name start with New or Los otherwise print blank
1 parent baa05ac commit 97e14c1

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

CheckTheStrinEndsWithScriptOrNot.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}

PrintTheNameOfTheCity.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
}

0 commit comments

Comments
 (0)