JavaScript Basic Concept

learn javascript
const sentence = "Mohammad Shohag";
const index = 9;
console.log(`Character at index ${index} is ${sentence.charAt(index)}`);
const str1 = ‘Software’;
const str2 = ‘Engineer’;
console.log(str1.concat(‘ ‘, str2));
const sentence = ‘My full name is Mohammad Shohag’;
const word = ‘Shohag’;
console.log(`The word “${word}” ${sentence.includes(word) ? ‘is’ : ‘is not’} available in the sentence`);
const str1 = ‘Software Engineer’;
console.log(str1.endsWith(‘Engineer’));
const str1 = ‘Software Engineer’;
console.log(str1.endsWith(‘Doctor’));
const paragraph = ‘I am Shohag from Bangladesh’;
const searchTerm = ‘from’;
const result = paragraph.indexOf(searchTerm);
console.log(`searching word position is ${result}`);
const paragraph = ‘I am from Bangladesh and I am learning JavaScript’;
const searchTerm = ‘am’;
console.log(`searching word “${searchTerm}” from the end is ${paragraph.lastIndexOf(searchTerm)}`);
const p = ‘A tech company can be giant if there is real tech heroes’;
console.log(p.replace(‘tech’, ‘garments’));
const str = ‘I love JavaScript so much’;
console.log(str.slice(2));
console.log(str.slice(2, 17));
console.log(str.slice(-7));
console.log(str.slice(-4, -2));
const str = ‘Hey Programming is fun’;
const words = str.split(‘ ‘);
console.log(words[1]);
const str1 = ‘Saturday night plans’;
console.log(str1.startsWith(‘Sat’));
const str = ‘Mozilla’; 
console.log(str.substr(1, 2));
const text = ‘HELLO Developers How Are You.’;
console.log(text.toLowerCase());
const text = ‘HELLO Developers How Are You.’;
console.log(text.toUpperCase());
const greeting = ‘  Hello world!  ‘;
console.log(greeting.trim());

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store