O'rnatilgan usullardan foydalangan holda stringni tekshiring
JavaScript
xxxxxxxxxx
function checkString(str) {
if(str.startsWith('S') && str.endsWith('G')) {
console.log('The string starts with S and ends with G');
}
else if(str.startsWith('S')) {
console.log('The string starts with S but does not end with G');
}
else if(str.endsWith('G')) {
console.log('The string starts does not with S but end with G');
}
else {
console.log('The string does not start with S and does not end with G');
}
}
let string = prompt('Enter a string: ');
checkString(string);
Enter a string: String The string starts with S but does not end with G
Regex yordamida satrni tekshiring
JavaScript
xxxxxxxxxx
function checkString(str) {
if( /^S/i.test(str) && /G$/i.test(str)) {
console.log('The string starts with S and ends with G');
}
else if(/^S/i.test(str)) {
console.log('The string starts with S but does not ends with G');
}
else if(/G$/i.test(str)) {
console.log('The string starts does not with S but ends with G');
}
else {
console.log('The string does not start with S and does not end with G');
}
}
for (let i = 0; i < 3; i++) {
const string = prompt('Enter a string: ');
checkString(string);
}
Enter a string: String The string starts with S and ends with G Enter a string: string The string starts with S and ends with G Enter a string: JavaScript The string does not start with S and does not end with G
Linux - anc-api-tools qanday o'rnatiladi
Linux - curvedns qanday o'rnatiladi
Linux - zenmap qanday o'rnatiladi
Python - Raqamning ijobiy, salbiy yoki 0 ekanligini tekshiring
C - Butun sondagi raqamlar sonini sanash
C++ - Raqam tub yoki oddiy emasligini tekshiring
C - Dinamik xotira ajratish yordamida eng katta raqamni toping
C++ - Kabisa yilini tekshiring
Kotlin - Raqamni teskari aylantirish
Linux - zstd qanday o'rnatiladi
C++ - Qism va qoldiqni toping
Kotlin - Sonning faktorialini toping
Python - Excel (XLSX) fayllarini yozish
Linux - xbitmaps qanday o'rnatiladi
Java - Raqamni teskari aylantirish
Kotlin - Raqamni n o‘nlik kasrgacha yaxlitlash
Java - Piramida va naqsh yarating
Linux - zfs-test qanday o'rnatiladi
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month