js is function
if(typeof test === "function") {
console.log('test is a function');
}else {
console.log('test is not a function');
}
js is function
if(typeof test === "function") {
console.log('test is a function');
}else {
console.log('test is not a function');
}
How does function and for of works in javascript?
const products = [
{ name: 'Laptop', price: 32000, brand: 'Lenovo', color: 'Silver' },
{ name: 'Phone', price: 700, brand: 'Iphone', color: 'Golden' },
{ name: 'Watch', price: 3000, brand: 'Casio', color: 'Yellow' },
{ name: 'Aunglass', price: 300, brand: 'Ribon', color: 'Blue' },
{ name: 'Camera', price: 9000, brand: 'Lenovo', color: 'Gray' },
];
function myFun() {
let getTotal = 0;
for (let product of products) { //for of loop
getTotal += product.price; //getTotal = getTotal + product.price;
}
return getTotal;
}
const result = myFun();
console.log(result);
//Expected output:45000
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us