pull/428/head
Ashim Debnath 8 months ago
parent 0b8a0fa568
commit 438d57739f

@ -1,79 +1,102 @@
let arr1 = [] // let arr1 = []
let arr2 = [10,20,30,40,50,60,70] // let arr2 = [10,20,30,40,50,60,70]
console.log(arr2.length) // console.log(arr2.length)
console.log(arr2[0]) // console.log(arr2[0])
console.log(arr2[Math.floor((arr2.length-1)/2)]) // console.log(arr2[Math.floor((arr2.length-1)/2)])
console.log(arr2[arr2.length-1]) // console.log(arr2[arr2.length-1])
let mixedDataTypes = [1,"Ashim",['Apple','Mango','Jackfruit'],true,3.14,333] // let mixedDataTypes = [1,"Ashim",['Apple','Mango','Jackfruit'],true,3.14,333]
console.log(mixedDataTypes.length) // console.log(mixedDataTypes.length)
let itCompanies = ["Facebook", "Google" , "Microsoft" , "Apple" , "IBM" , "Oracle", "Amazon", "Jio"] // let itCompanies = ["Facebook", "Google" , "Microsoft" , "Apple" , "IBM" , "Oracle", "Amazon", "Jio"]
console.log(itCompanies) // console.log(itCompanies)
console.log("there are " + itCompanies.length + " IT Companies") // console.log("there are " + itCompanies.length + " IT Companies")
console.log("The first company is "+ itCompanies[0]) // console.log("The first company is "+ itCompanies[0])
console.log("The last company is "+ itCompanies[itCompanies.length-1]) // console.log("The last company is "+ itCompanies[itCompanies.length-1])
console.log("The middle company is "+ itCompanies[Math.floor((itCompanies.length-1)/2)]) // console.log("The middle company is "+ itCompanies[Math.floor((itCompanies.length-1)/2)])
console.log("All the IT companies are :"+ itCompanies.join(", ")) // console.log("All the IT companies are :"+ itCompanies.join(", "))
console.log(itCompanies[0].toUpperCase()) // console.log(itCompanies[0].toUpperCase())
console.log(itCompanies[1].toUpperCase()) // console.log(itCompanies[1].toUpperCase())
console.log(itCompanies[2].toUpperCase()) // console.log(itCompanies[2].toUpperCase())
console.log(itCompanies[3].toUpperCase()) // console.log(itCompanies[3].toUpperCase())
console.log(itCompanies[4].toUpperCase()) // console.log(itCompanies[4].toUpperCase())
console.log(itCompanies[5].toUpperCase()) // console.log(itCompanies[5].toUpperCase())
console.log(itCompanies.toString()) // console.log(itCompanies.toString())
let index = itCompanies.includes("Apples") // let index = itCompanies.includes("Apples")
if(index){ // if(index){
console.log("The Item exists in the array") // console.log("The Item exists in the array")
}else{ // }else{
console.log("The Item does not exist") // console.log("The Item does not exist")
} // }
let reqComp = []; // let reqComp = [];
for(let i = 0 ; i < itCompanies.length ; i++){ // for(let i = 0 ; i < itCompanies.length ; i++){
if(itCompanies[i].includes('o')){ // if(itCompanies[i].includes('o')){
let company = itCompanies[i].toLowerCase().split('') // let company = itCompanies[i].toLowerCase().split('')
//console.log(company) // //console.log(company)
let count = 0; // let count = 0;
for(let j = 0 ; j < company.length ; j++){ // for(let j = 0 ; j < company.length ; j++){
if(company[j] == 'o'){ // if(company[j] == 'o'){
count += 1; // count += 1;
} // }
} // }
if(count > 1){ // if(count > 1){
reqComp.push(itCompanies[i]) // reqComp.push(itCompanies[i])
} // }
} // }
} // }
console.log(reqComp) // console.log(reqComp)
console.log(itCompanies.sort()) // console.log(itCompanies.sort())
console.log(itCompanies.reverse()) // console.log(itCompanies.reverse())
onsole.log(itCompanies.slice(0,3)) // onsole.log(itCompanies.slice(0,3))
//console.log(itCompanies.splice(4,)) // //console.log(itCompanies.splice(4,))
let length = itCompanies.length // let length = itCompanies.length
let lower = Math.floor((length-1)/2) // let lower = Math.floor((length-1)/2)
let upper = Math.ceil((length-1)/2) // let upper = Math.ceil((length-1)/2)
console.log(lower) // console.log(lower)
console.log(upper) // console.log(upper)
console.log(itCompanies.slice(lower , upper+1)) // console.log(itCompanies.slice(lower , upper+1))
itCompanies.splice(0,1) // itCompanies.splice(0,1)
console.log(itCompanies) // console.log(itCompanies)
let floorMid = Math.floor((length-1)/2) // let floorMid = Math.floor((length-1)/2)
let ceilMid = Math.ceil((length-1)/2) // let ceilMid = Math.ceil((length-1)/2)
if(length%2 == 0){ // if(length%2 == 0){
itCompanies.splice(floorMid,2) // itCompanies.splice(floorMid,2)
}else{ // }else{
itCompanies.splice(floorMid,1) // itCompanies.splice(floorMid,1)
} // }
console.log(itCompanies) // console.log(itCompanies)
// itCompanies.splice(itCompanies.length-1,1)
// console.log(itCompanies)
// itCompanies.splice(0)
// console.log(itCompanies)
itCompanies.splice(itCompanies.length-1,1)
console.log(itCompanies)
itCompanies.splice(0) let dogs = {}
console.log(itCompanies)
console.log(dogs)
dogs.name = "Tommy";
dogs.legs = 4;
dogs.color = "brown";
dogs.age = 5
dogs.bark = function(){
return "woof woof";
}
console.log(dogs.name)
console.log(dogs.legs)
console.log(dogs.age)
console.log(dogs.color)
console.log(dogs.bark())
dogs.breed = "germen sheford"
dogs.getDogInfo = function(){
return `name: ${this.name} , color : ${this.color} , age : ${this.age} , breed : ${this.breed}`
}
console.log(dogs.getDogInfo());

@ -1,51 +1,137 @@
import webTechs from "./web_techs.mjs"; // import webTechs from "./web_techs.mjs";
import countries from "./countries.mjs"; // import countries from "./countries.mjs";
// console.log(webTechs) // // console.log(webTechs)
// console.log(countries) // // console.log(countries)
let text = // let text =
'I love teaching and empowering people. I teach HTML, CSS, JS, React, Python.' // 'I love teaching and empowering people. I teach HTML, CSS, JS, React, Python.'
let words = text.split(" ") // let words = text.split(" ")
console.log(words) // console.log(words)
console.log(words.length) // console.log(words.length)
const shoppingCart = ['Milk', 'Coffee', 'Tea', 'Honey'] // const shoppingCart = ['Milk', 'Coffee', 'Tea', 'Honey']
if(shoppingCart[0]!="Meat"){ // if(shoppingCart[0]!="Meat"){
shoppingCart.unshift("Meat") // shoppingCart.unshift("Meat")
}console.log(shoppingCart) // }console.log(shoppingCart)
if(shoppingCart[shoppingCart.length-1]!="Sugar"){ // if(shoppingCart[shoppingCart.length-1]!="Sugar"){
shoppingCart.push("Sugar") // shoppingCart.push("Sugar")
}console.log(shoppingCart) // }console.log(shoppingCart)
const Allergy = true // const Allergy = true
if(Allergy==true){ // if(Allergy==true){
let i = shoppingCart.indexOf('Honey') // let i = shoppingCart.indexOf('Honey')
shoppingCart.splice(i,1) // shoppingCart.splice(i,1)
}console.log(shoppingCart) // }console.log(shoppingCart)
let index = shoppingCart.indexOf('Tea') // let index = shoppingCart.indexOf('Tea')
shoppingCart[index] = 'Green Tea' // shoppingCart[index] = 'Green Tea'
console.log(shoppingCart) // console.log(shoppingCart)
if(countries.includes("Ethiopia")){ // if(countries.includes("Ethiopia")){
console.log("ETHIOPIA") // console.log("ETHIOPIA")
}else{ // }else{
countries.push('Ethiopia') // countries.push('Ethiopia')
} // }
// if(webTechs.includes('Sass')){
// console.log("sass is a css preprocessor")
// }else{
// webTechs.push("Sass")
// }console.log(webTechs)
if(webTechs.includes('Sass')){ // const frontEnd = ['HTML', 'CSS', 'JS', 'React', 'Redux']
console.log("sass is a css preprocessor") // const backEnd = ['Node', 'Express', 'MongoDB']
}else{ // let fullStack = frontEnd.concat(backEnd)
webTechs.push("Sass") // console.log(fullStack)
}console.log(webTechs)
const frontEnd = ['HTML', 'CSS', 'JS', 'React', 'Redux'] const users = {
const backEnd = ['Node', 'Express', 'MongoDB'] Alex: {
let fullStack = frontEnd.concat(backEnd) email: 'alex@alex.com',
console.log(fullStack) skills: ['HTML', 'CSS', 'JavaScript'],
age: 20,
isLoggedIn: false,
points: 30
},
Asab: {
email: 'asab@asab.com',
skills: ['HTML', 'CSS', 'JavaScript', 'Redux', 'MongoDB', 'Express', 'React', 'Node'],
age: 25,
isLoggedIn: false,
points: 50
},
Brook: {
email: 'daniel@daniel.com',
skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux'],
age: 30,
isLoggedIn: true,
points: 50
},
Daniel: {
email: 'daniel@alex.com',
skills: ['HTML', 'CSS', 'JavaScript', 'Python'],
age: 20,
isLoggedIn: false,
points: 40
},
John: {
email: 'john@john.com',
skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux', 'Node.js'],
age: 20,
isLoggedIn: true,
points: 50
},
Thomas: {
email: 'thomas@thomas.com',
skills: ['HTML', 'CSS', 'JavaScript', 'React'],
age: 20,
isLoggedIn: false,
points: 40
},
Paul: {
email: 'paul@paul.com',
skills: ['HTML', 'CSS', 'JavaScript', 'MongoDB', 'Express', 'React', 'Node'],
age: 20,
isLoggedIn: false,
points: 40
}
}
let mostSkills = 0;
let mostSkilled = null;
let loggedin = [];
let pointsMoreThan50 = [];
let mern = [];
for ( const user in users){
if(users[user].skills.length > mostSkills){
mostSkills = users[user].skills.length;
mostSkilled = user
}
if(users[user].isLoggedIn){
loggedin.push(user)
}
if(users[user].points >= 50){
pointsMoreThan50.push(user)
}
if(users[user].skills.includes('MongoDB','Express','React','Node')){
mern.push(user)
}
}
// console.log(mostSkilled)
// console.log(loggedin)
// console.log(pointsMoreThan50)
console.log(mern)
users.Ashim = {email : "ashimdebanth6767@gmail.com",
skills :['HTML','CSS','Javascript','MongoDB','Express','React','Node'],
age : 21,
isLoggedIn : true,
points : 40
}
console.log(users)
console.log(Object.keys(users))
console.log(Object.values(users))

@ -0,0 +1,20 @@
import countries from "./countries.mjs"
const ages = [19, 22, 19, 24, 20, 25, 26, 24, 25, 24]
ages.sort()
console.log(ages)
console.log("min age = "+ages[0])
console.log("max age= "+ ages[ages.length-1])
let start = Math.floor((ages.length-1)/2)
let end = Math.ceil((ages.length-1)/2)
console.log("median age is= "+ ages.slice(start,end+1))
let sum =0;
for(let i =0 ; i< ages.length ; i++){
sum+= ages[i]
}
console.log("average age = "+ sum/ages.length)
console.log("Range of age = " + (ages[ages.length-1]-ages[0]))
console.log(countries.slice(0,10))
let start1 = Math.floor((countries.length-1)/2)
let end1 = Math.ceil((countries.length-1)/2)
console.log("median age is= "+ countries.slice(start1,end1+1))

@ -0,0 +1,3 @@
console.log(mostSkilled)
// console.log(loggedin)
// console.log(pointsMoreThan50)
Loading…
Cancel
Save