Back to Top

JavaScript Practice Raw Code

let activeNav = document.getElementsByClassName('active');
let submenu = document.getElementById('subMenu');
submenu.style.display = "none";

let isDriver = false;

let isNull = null;

let isUndefined = undefined;

let data = ['Apple','Orange', 'Banana'];

function menuFunction(){
submenu.style.display = "block";
}


console.log(`The data type is ` + (typeof menuFunction));
console.log(`The data type is ` + (typeof submenu));
console.log(`The data type is ` + (typeof isDriver));
console.log(`The data type is ` + (typeof isNull));
console.log(`The data type is ` + (typeof isUndefined));
console.log(`The data type is ` + (typeof data));

// ============================ Type of DataType in JavaScript =================================== //

/* Notes Primitive Datatypes are

String
Number
Boolean
null
undefined

--> Stack Memory Alocation
*/



/* Notes Refrence Datatypes are

Array()
function
objectLitral
Date

--> Heap Memory Alocation
*/

let floatValue = parseFloat(253.65);
let f = floatValue.toFixed(1);

f = Number(true);

console.log(f.length, (typeof f));

let fire = Number("95");
let isString = String(50);
console.log(isString, (typeof isString));
console.log(fire, (typeof fire));
fire = 35;
let convertToString = fire.toString();
console.log(convertToString, (typeof convertToString));

let date = String(new Date());

let isDoctor = Number(false);
isDoctor = Number(true);
isDoctor = Boolean(1);



console.log(date, (typeof date));

console.log(isDoctor, (typeof isDoctor));

let details = 'Hello, this is, my, JavaScript, String';

let split = details.split(',');

console.table('String covert into Array',split, split.length, (typeof split));
console.table(split.indexOf(' JavaScript'));
console.table(split.includes('String'));
console.log(details.endsWith('String'));

console.log('JavaScript change to NodeJS', details.replace('JavaScript', 'NodeJS'));
console.log('All comma remove with replace regular expresssion', details.replace(/,/g, ' '));


var iHaveManyCommans = "Once, upon, a, time, long, long, ago";
var howManyCommasDoIHave = iHaveManyCommans.split(',').join(' ');

console.log(howManyCommasDoIHave);


let names = ["Mike","Matt","Nancy","Adam","Jenny","Nancy","Carl"];

let removeDublicatesFromName = [...new Set(names)];



console.log(removeDublicatesFromName);




const fruits = ['Apple','Banana','Orange', 'Mengo','Apple','Orange','Banana'];

//const removeDublicatesFruits = [...];

const removeDublicatesFruits = Array.from(new Set(fruits));


document.querySelector("#fruitsDropDown").innerHTML = `
${removeDublicatesFruits.map(value => {
return `<option>${value}</option>`
})}`

console.clear();

const fruitsCollection = ['Apple','Banana','Orange', 'Mengo'];
const covertArrayToString = fruitsCollection.join(' ');
console.log(covertArrayToString);



let getImages = document.images;

Array.from(getImages).forEach((ele) => {
if(ele.src.includes('.jpg')){
console.log(ele.src);
}
})

let ourClientsDomain = ['www.mahishadal.com','www.tvbangla.co.in','www.bengalnewsnetwork.com', 'wwww.bangaloremedical.in','www.ecodedesign.com'];


Array.from(ourClientsDomain).forEach((filterDomain) => {
if(filterDomain.includes('.com')){
console.log(`${filterDomain}`);
}
})


console.clear();

let users = [
{
userName: 'Md Shahid',
email: 'developer@gmail.com',
},
{
userName: 'Rahul Lal',
email: 'rahul.lal@gmail.com',
},
{
userName: 'Priyanka Shaw',
email: 'priyanka@gmail.com',
},
{
userName: 'Code With Harry',
email: 'codewithharry@gmail.com',
},
{
userName: 'Md Irfan',
email: 'mdirfan@gmail.com',
},
];

Array.from(users).forEach((el) => {
userList = el.userName;
userEmail = el.email;

function setupEmailTemplate(userList, userEmail){
return `Hello ${userList},
Welcome To Mahishadal Swimmimng club.
Wishing you a year that is filled with all the fragrance of roses, illuminated with all the lights of the world and be blessed with all the smiles on the planet. Hope this year will be the year when all your dreams come true.
Please Contact us : ${userEmail}
`;
};

console.log(setupEmailTemplate(userList, userEmail));

// let incomminEmails = setupEmailTemplate(userList, userEmail);

// document.getElementById('emailBox').innerHTML = setupEmailTemplate(userList, userEmail);

//document.getElementsByClassName('emailBox').innerHTML = setupEmailTemplate(userList, userEmail);

})



/******

Array.from(users).forEach((el) => {
if(el.userName.includes('Md')){
userList = el.userName;
userEmail = el.email;


function setupEmailTemplate(userList, userEmail){
return `Hello ${userList},
Welcome To Mahishadal Swimmimng club.
Wishing you a year that is filled with all the fragrance of roses, illuminated with all the lights of the world and be blessed with all the smiles on the planet. Hope this year will be the year when all your dreams come true.
Please Contact us : ${userEmail}
`;
};

console.log(setupEmailTemplate(userList, userEmail));

}
})


***/







/***

function setupEmailTemplate(name, email){
return `Hello ${name},
Welcome To Mahishadal Swimmimng club.
Wishing you a year that is filled with all the fragrance of roses, illuminated with all the lights of the world and be blessed with all the smiles on the planet. Hope this year will be the year when all your dreams come true.


Please Contact us : ${email}
`;
};



console.log(setupEmailTemplate('Shahid','developer@gmail.com'));

console.log(setupEmailTemplate('Nagma','nagma@gmail.com'));

*/