JavaScript Code Snippet
..
A quick snippet of my code today
//string length
console.log(fullName.length); //it counted the space in btw as a character
//string methods.
//There is a difference btw functions and methos but you are going to use them interchangeably.
//A funtion is a snippet of code which performs some kind of specific task.
//A method is just a funtion that is associated with a particular object od or datatype.
//string method
console.log(fullName.toUpperCase()); //its not a snippet of code to do something like a fuction, its just finding out the property of that code.
let result = fullName.toLowerCase();
console.log(result, fullName);
let index = email.indexOf('@');//we want it to find the index of the @ symbol, this is alled an argument but they can also be called a parameter.
console.log(index);
//Strings, a series of characters, letters of numbers in quotes.
//They have ppt like the length and we use notation
//They have ppt like the lenght and we use dot noations to get those ppt.
let emaill ='imaginesdes@galaxy.universe';
console.log(emaill); //when I used email as the variable name before I changed it to 'emaill', it flagged an error and told me it has been declared.
let resultt = emaill.lastIndexOf('n'); //I noticed u have to use camel casing for this method, if not it would not work.
console.log(resultt);
//The slice method, slices a section from the string
let resultt2 = emaill.slice(2,5); //position 0 where we want to start or slice from, position we want to slice to 10. So from 0 to 10.
console.log(resultt2);
//To make a substring from the values of mail.
let resultt3 = email.substr(0,7); //It's very much like slice but the two arguments represents something different thing.
// It starts from position 0, but the next number in the parenthesis means how many character we want to go along.
console.log(resultt3);
// To use the replace
let resultt4 = email.replace('i', 'e'); //It will find the first i in the word and replace it with an e.
console.log(resultt4); //You should know it will only replace the first n. You can do something similar with regular expressions,
..