20:00 we can also duplicate this array by using spread operators , const duplicate = (arr)=>{ return newArray = [...arr, ...arr] } console.log(duplicate([1, 2, 3])) It will return an new array
i had the same question back then, dont stress it , its pretty simple, when you use return , the data after it can be stored in a variable and can be accessed whenever you want, unlike consolelog , it just prints the data, whereas return stores it@@CreativKun
1:36:56 for most frequent item of array we can also do it very easily instead of using objects(by your method) use my method : function frequent(arr){ let ans = arr.reduce( (acc,num)=>{ return freq[acc] > freq[num] ? acc : num; }) console.log(ans); } frequent([1,2,3,4,1,4,3,1,3,7,])
very nice video broo ... for question 10 you can use reduce method also ,,,,const string='apple' const result = string.split('').reduce((acc,curr)=>{ if(acc[curr]){ acc[curr]= ++acc[curr]; }else{ acc[curr]=1; } return acc; },{}); console.log(result);
Loop: add list of all members in array which is number. (ex: 4 or '4') Optimal Solution: Remember check all the edge cases. let members = [1,'fh','4','foo',5, '6']; const addMembers = members => { let count = 0; members.forEach(member => { if (!isNaN(Number(member))) { count += Number(member); } }) return count; } console.log(addMembers(members));
Hi Harsh brother - ur teaching style n the content u've provided hv been incredibly helpful 2 all of us. The way u explain complex concepts with clarity and enthusiasm truly makes a difference in our understanding.
And i did like this very small change but I understand better in this way: // shuffle an array const array = [1, 2, 3, 4, 5, 6, 7, 8, 9]; const shuffler = (arr) => { for (let i = arr.length - 1; i > 0; i--) { let rendomIndex = Math.floor(Math.random() * arr.length) let temp = arr[i] arr[i] = arr[rendomIndex] arr[rendomIndex] = temp } return arr } console.log(shuffler(array));
// shuffle given array function shuffleArray() { let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]; arr.sort((a, b) => Math.random() - 0.5); console.log(arr); } shuffleArray(); this should also work
1:09:24 we can also use let arr=[ {name:"abcd",gender:"male"}, {name:"hrssfd",gender:"female"}, {name:"fsdfsd",gender:"female"} ] for(let i of arr){ if(i.gender !="male"){ continue; }else{ console.log(i) } }
your effors are well appreciated. Practising Javascript is the only way to become an good Frontend or even backend developer. But most of the times we learn ReactJs, Anglular any such frontend libraries is of no use. The more you practice, the better you will become.
Just a friendly reminder, during interview they expect you to use self made code. You can't use pre defined methods. Like sort, reverse etc. So prepare accordingly. All the best guys😁😁
function shuffleArray() { let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]; for (let i=arr.length-1; i>0; i--) { let random = Math.floor(Math.random() * (i+1)); [arr[i], arr[random]] = [arr[random], arr[i]]; } console.log(arr); } shuffleArray(); this could be more easy & effective
bhaiya can we do this also var array = [1, 2, 3, 4, 5, 6,7 ,8 ,9, 0]; var emptyArray = array.splice(array.length, array.length) console.log(emptyArray)
function retrive(arr, ele = 1) { if (arr.length >= ele) { console.log(arr.slice(-ele)) }else{ console.log(`${ele} Elements nahi hai Arry me `) } } retrive([1, 2, 3, 4, 5, 6, 7], 1) print last elements
Sir please kuch questions ka solution bhut jada ghumane valla tha specially frequent element and shuffle valla pls sir in 2 programs ka koi simple solution bta dijiye.....baki sb smj a gya h ....and thankyou so much itna acha padane ke lieee
Sir aap explain bahut achese kar rahe hain but jo background sound hai wo thoda sa disturb kar rhi hai concentrate hoke sunne me... Aapne bahut achi tarah se samjhaye hai problems mujhe saare samjh aaye per sound ne thoda sa problem diya other wise 10/9 .1 marks for sound
Because reverse method is for array it is not operate on string that's why we have to split string into a array then reverse it and join the array elements into string
// Write a javascript program to compute the union of two arrays let newArr = [1,2,3,4,5,6,7,8,9,10]; let newArr2 = [9,10,11,12,13,14,15,16,17,18]; function union(arr1, arr2){ console.log([...new Set(arr1.concat(arr2))]); // return [...new Set(arr1.concat(arr2))]; } console.log(union(newArr, newArr2)); //Question : Why is there showing undefined showing in the output?
sir kya is question ko aise bhi kr sakte hain???? // 16. write a javascript function to get the last element of an array. Passing a // parameter 'n' will return the last 'n' element of the array // and should not come undefined value // function arr(e,n=2) // { // const res = e.reverse() // if(n
Question 4:- if you take number 0.1 it will give you Integer it will be failed in this situation any alternative approach ? If someone knows just drop ur logic ❤️
Sir, Please make more questions like this it really help me a lot to undertstand the concept in so many other ways...................Waiting for more questions like this!!!!!!!!!!!
500 Likes and 150 comments ka target that for the next Questions video ab to Biya 6.3K likes and 318 Comments ho chukay hain so please continue this series ek alag playlist bnayn for Questions and bring more basic to advance JavaScript Questions on all JS topics, Thankyou.
Sir please make full course on html ,css, javascript, full stack developer course Please sir I like the way u teach !!! Please sir highly requested...🙇
Sir , instead of using object to remove duplicate elements from an array can we convert first into set and then Array.from(set) by this way we got the array with unique numbers
bhai muze laga Q.5. ka ans mai solve kr sakta hu to maine solve kiya but aapka ans dekhkr meri shakal 😳 . my Ans. - function duplicate(val){ var sampl = []; for(let i=0; i
Your teaching skill is amazing.... explore many things that are easy but never thing on that way...bus aap problem solve karte joke karte ho... usme aisa lagta he k jaise koi lorry driver drive karte karte joke mar raha he... 😂😂😂
Thank you so much Harsh for putting together this important video! Really appreciate the hours of work you and your team put into recording/editing these videos all for free. Would like to support you by buying paid courses.
/* 11:: Write a JavaScript function to get the first element of an array. Passing a barameter 'n' will return the first 'n' elements of the array. */ const retrieveNthFirstEle = (arr = [], n = 1) => { if (arr.length === 0 || n { if (arr.length === 0 || n = arr.length) return arr return arr.slice(-n); } console.log(retrieveNthLastEle([1,2,3,4,5,6,7], 2))
20:00 we can also duplicate this array by using spread operators ,
const duplicate = (arr)=>{
return newArray = [...arr, ...arr]
}
console.log(duplicate([1, 2, 3]))
It will return an new array
can you explain me What return Keyword Do???
@@CreativKunThe return keyword returns the value where the function is called.
i had the same question back then, dont stress it , its pretty simple, when you use return , the data after it can be stored in a variable and can be accessed whenever you want, unlike consolelog , it just prints the data, whereas return stores it@@CreativKun
@@kaushikbora2728 Thanks a lot
Hi sir please upload for complete javascript course I like your teaching style.
I also feel the same, solving complex problems very easily sir✨
It's already there. check their playlist it's LIT🔥
1:22:00 we can also use
function retrieve(arr, n = 1){
return arr.slice(0,n);
}
1:36:56 for most frequent item of array we can also do it very easily instead of using objects(by your method) use my method :
function frequent(arr){
let ans = arr.reduce( (acc,num)=>{
return freq[acc] > freq[num] ? acc : num;
})
console.log(ans);
}
frequent([1,2,3,4,1,4,3,1,3,7,])
Q5 : => 2 method
let a = [1,2,3,];
console.log(a += a)
very nice video broo ... for question 10 you can use reduce method also ,,,,const string='apple'
const result = string.split('').reduce((acc,curr)=>{
if(acc[curr]){
acc[curr]= ++acc[curr];
}else{
acc[curr]=1;
}
return acc;
},{});
console.log(result);
1:12:50
for(i=0;i
Array 10: Return data types: check all the corner cases.
const returnDataType = (variable) => {
if (typeof variable === 'object') {
if (Array.isArray(variable)) return 'array';
if (variable === null) return null;
return 'object'
}
return typeof variable;
}
console.log(returnDataType(function(){}))
37th question can be done in a single for loop
for(var i=0; i
agar ham ye use karenge to agar do consecutive females aayi to doosra vala object check hi nhi hoga
Loop: add list of all members in array which is number. (ex: 4 or '4')
Optimal Solution: Remember check all the edge cases.
let members = [1,'fh','4','foo',5, '6'];
const addMembers = members => {
let count = 0;
members.forEach(member => {
if (!isNaN(Number(member))) {
count += Number(member);
}
})
return count;
}
console.log(addMembers(members));
Hi Harsh brother - ur teaching style n the content u've provided hv been incredibly helpful 2 all of us. The way u explain complex concepts with clarity and enthusiasm truly makes a difference in our understanding.
Q. Loop an array and all all elem in it..
arr.map((ele) => {
sum+= ele;
})
console.log(sum)
Are sir please aise videos aur Lao js ki intuition build ho rhi hai meri aj phli bar sare questions aa gye
Shuffle array question answer in more smaller way
let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
arr.sort(() => Math.random() - 0.5);
console.log(`Shuffled array: ${arr}`);
And i did like this very small change but I understand better in this way:
// shuffle an array
const array = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const shuffler = (arr) => {
for (let i = arr.length - 1; i > 0; i--) {
let rendomIndex = Math.floor(Math.random() * arr.length)
let temp = arr[i]
arr[i] = arr[rendomIndex]
arr[rendomIndex] = temp
}
return arr
}
console.log(shuffler(array));
// shuffle given array
function shuffleArray() {
let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
arr.sort((a, b) => Math.random() - 0.5);
console.log(arr);
}
shuffleArray();
this should also work
For male question we can do it in single loop for(let i = arr.length-1 ; i >=0; i--){
If condition here
}
1:09:24 we can also use
let arr=[
{name:"abcd",gender:"male"},
{name:"hrssfd",gender:"female"},
{name:"fsdfsd",gender:"female"}
]
for(let i of arr){
if(i.gender !="male"){
continue;
}else{
console.log(i)
}
}
retrun values.forEach(function(obj, index, arr) {
if (obj.gender=== "male") {
arr.splice(index, 1);
}
your effors are well appreciated. Practising Javascript is the only way to become an good Frontend or even backend developer. But most of the times we learn ReactJs, Anglular any such frontend libraries is of no use. The more you practice, the better you will become.
I used arr.splice(0) to empty the array.
Got to know today that it's can be done by setting array length to 0 also😊
This is very helpful !!
Thankyou so much ❤️
yes..
Hi Harsh, Question - program to find frequent number is tough & hard to understand, so how can i solve it.
Maazaa agaya bhaiyaa!
Just had a req, that pls avoid any background music henceforth. It becomes irritating at a certain point
Thanks bro now I have mastered JavaScript as well as Persian 🛐
It's literally mind-blowing 🤯🤯🤯🤯...
Please one more video same as it is🔥🔥🔥🔥,
like a interview problem solving... 😍😍😍
Just a friendly reminder, during interview they expect you to use self made code. You can't use pre defined methods. Like sort, reverse etc. So prepare accordingly. All the best guys😁😁
give me more tips brother
That's totally true.
background me jo music bjta hai ekdum slow me kaafi relaxing lagta hai aapne saare videos me daalo bhaya..
1:06:14 !!! brilliant answer type
sir ye sahi hai question no 3=> let arr=[1,2,3,4,5,6,5,6,7,8]
let a=arr.splice(0,arr.length)
console.log(arr)
function shuffleArray() {
let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
for (let i=arr.length-1; i>0; i--) {
let random = Math.floor(Math.random() * (i+1));
[arr[i], arr[random]] = [arr[random], arr[i]];
}
console.log(arr);
}
shuffleArray();
this could be more easy & effective
bhaiya can we do this also
var array = [1, 2, 3, 4, 5, 6,7 ,8 ,9, 0];
var emptyArray = array.splice(array.length, array.length)
console.log(emptyArray)
function retrive(arr, ele = 1) {
if (arr.length >= ele) {
console.log(arr.slice(-ele))
}else{
console.log(`${ele} Elements nahi hai Arry me `)
}
}
retrive([1, 2, 3, 4, 5, 6, 7], 1)
print last elements
Problem number 3 solution:
function emptyArray(arr) {
return arr.filter((item) => !item);
}
console.log(emptyArray([1, 5, 8, 63]));
Sir please kuch questions ka solution bhut jada ghumane valla tha specially frequent element and shuffle valla pls sir in 2 programs ka koi simple solution bta dijiye.....baki sb smj a gya h ....and thankyou so much itna acha padane ke lieee
Reverse Number:: Including negative value
function reverseNumber(num) {
let reversed = 0;
let sign = Math.sign(num);
num = Math.abs(num);
while (num > 0) {
reversed = reversed * 10 + num%10;
num = Math.floor(num / 10);
}
return reversed * sign;
}
console.log(reverseNumber(-12300)); // -321
console.log(reverseNumber(123)); // 321
console.log(reverseNumber(450000)); // 54
Love you sir job lg gyi to phle salary se apka hi course kharidunga
ab ese kehte hai sikhana pura explain karke thank you bhaiya....
For Genders Question (Using Filter First and then For Loop):::::::::::for (var j = 0; j < arr.length; ) {
if (arr[j].gender !== 'male') {
arr.splice(j, 1);
} else {
j++;
}
}
Please upload some more videos like this by taking some kor difficult problems using Javascript
Sir aap explain bahut achese kar rahe hain but jo background sound hai wo thoda sa disturb kar rhi hai concentrate hoke sunne me... Aapne bahut achi tarah se samjhaye hai problems mujhe saare samjh aaye per sound ne thoda sa problem diya other wise 10/9 .1 marks for sound
Because reverse method is for array it is not operate on string that's why we have to split string into a array then reverse it and join the array elements into string
This is very helpful !!
Thankyou so much ❤
// Write a javascript program to compute the union of two arrays
let newArr = [1,2,3,4,5,6,7,8,9,10];
let newArr2 = [9,10,11,12,13,14,15,16,17,18];
function union(arr1, arr2){
console.log([...new Set(arr1.concat(arr2))]);
// return [...new Set(arr1.concat(arr2))];
}
console.log(union(newArr, newArr2));
//Question : Why is there showing undefined showing in the output?
One output is perfectly showing but another is undefined, What is the error?
Why commented the return statement? uncomment it, will work.
var str="hello sreehari how are you"
var reverseStr=(str.split("").reverse("").join(""));
console.log(reverseStr);
Aap boht hi acchese simple language me smjhate ho..Loved it❤️❤️
sir kya is question ko aise bhi kr sakte hain????
// 16. write a javascript function to get the last element of an array. Passing a
// parameter 'n' will return the last 'n' element of the array
// and should not come undefined value
// function arr(e,n=2)
// {
// const res = e.reverse()
// if(n
1:02:18
question removing object all object which gender != male
another solution
let people = [
{ name: "John", gender: "Male" },
{ name: "deepak", gender: 'undefind'},
{ name: "Emma", gender: "Female" },
{ name: "Alex", gender: "Male" },
{ name: "Sophia", gender: "Female" }
];
for(let i=0; i
Question 4:- if you take number 0.1 it will give you Integer it will be failed in this situation any alternative approach ? If someone knows just drop ur logic ❤️
THANK YOU SO MUCH SIR...... HUGE RESPECT 50% QUESTIONS I DID IT...
Sir, Please make more questions like this it really help me a lot to undertstand the concept in so many other ways...................Waiting for more questions like this!!!!!!!!!!!
harsh bhaiya ki teaching style❤ koi banda ubb hi nhi skta pdhte time😄
500 Likes and 150 comments ka target that for the next Questions video ab to Biya 6.3K likes and 318 Comments ho chukay hain so please continue this series ek alag playlist bnayn for Questions and bring more basic to advance JavaScript Questions on all JS topics, Thankyou.
sir please make this type of videos more it's help lot...... Thank you so much sir😇😇😇😇😇😇😇
What about string
Ex.- var a ="12"
Then also its giving integer
1:36:55 in the question to find most frequent item of array, how to solve it if more than one value occurs most time?
please replay
Very well explained, waiting for next 20 questions 🙌🏻🙌🏻
easy and hard at same time . but sara smj agaya bohut achiy sa smjhty hn ap
well a wonderfull journey of 2 hours come to an end it was worth it to watch and follow u thanks once again
have watched complete video
That Background Music Make this Much Easier To understand....that is the we want to learn whole Video is Just awosome Great Explaination...
8:15
Nimdaaa
Dosrass Sthelmi
Hardha-vhush KKRRAAK viku Nim-bhumla
Mohina ZukOOO...
Loha -KhuvAAA...
Bhaiya agle questions bhi daldo 👀😊
Please make some more videos,
It was very help full !important
Really appreciate your efforts...thankss
btw part 2 wasn't posted ?
Thank you for your teaching style-it makes everything much easier to understand. 😊
Sir please make full course on html ,css, javascript, full stack developer course
Please sir
I like the way u teach !!!
Please sir highly requested...🙇
19:40 the way he said 'Chauuuda'
Harsh Bhai, the way you teach is awesome, only I am distracted watching you when you adjust your glasses 👓 every15 secondsc.
Question 1: advanced solution with Palindrome problem.
const removeSpaceFromString = str => str.replace(/\s/g, '')
const reverse = str => str.split('').reverse().join('');
const ispalindrom = str => {
const isString = (typeof str === 'number') ? str.toString() : str;
const valueWithoutSpace = removeSpaceFromString(isString)
return (valueWithoutSpace === (reverse(valueWithoutSpace))) ? 'Palindrome' : 'Not Palindrome'
}
console.log(ispalindrom('m a m')) //Palindrome
console.log(ispalindrom(5.5)) // Palindrome
console.log(ispalindrom('deified')) // Palindrome
Bhaiya JS me chrome k devloper tools me debug functionality kis tarah se use ki jati hai ek video banao. cover what are breakpoints.
This teach styles and explanation is awesome 😮❤
Bro Dot Net development Ka Tutorial Lao Please Project ke sath
make a path, write in 30 points the interview questions from easy to difficult of the javascripts programming language
More optimal solution for gender based filter:
General filter:
const filterByGender = (users, gendersToFilter) => {
return users.filter(user => gendersToFilter.includes(user.gender))
}
console.log(filterByGender(users, ['male']))
Solution for Exclude:
const filterByGenderExcept = (users, gendersToExclude) => {
return users.filter(user => !gendersToExclude.includes(user.gender))
}
const users = [
{ name: 'abc', gender: 'male'},
{ name: 'cc', gender: 'female'},
{ name: 'bb', gender: 'any'},
{ name: 'dd', gender: 'female'}
]
console.log(filterByGenderExcept(users, ['male']))
bhaiya ek chota sa suggestion tha plz videos mai background music mat use kiya karo disturbance hota hai
53:33 ,1:13:03,1:22:08 ,1:29:15
Sir , instead of using object to remove duplicate elements from an array can we convert first into set and then Array.from(set) by this way we got the array with unique numbers
bhai muze laga Q.5. ka ans mai solve kr sakta hu to maine solve kiya but aapka ans dekhkr meri shakal 😳
.
my Ans. -
function duplicate(val){
var sampl = [];
for(let i=0; i
Your teaching skill is amazing.... explore many things that are easy but never thing on that way...bus aap problem solve karte joke karte ho... usme aisa lagta he k jaise koi lorry driver drive karte karte joke mar raha he... 😂😂😂
Hi Harsh
Can you please provide the doc which has only questions in it so that we can practice and see the solution
Thanks
Bahi you are amazing ..Love from Hyderabad Please Keep helping us bahi in our web development journey❤
33:52
25:25 agar hum 12340 pass kren then 4321 ata ha " 0 " value ni ati
Thank you so much Harsh for putting together this important video! Really appreciate the hours of work you and your team put into recording/editing these videos all for free. Would like to support you by buying paid courses.
we need more video like this plssss continue
awesome questions and teching style.
aage ke questions konsi video me hai?
/* 11:: Write a JavaScript function to get the first element of an array. Passing a barameter 'n' will return the first 'n' elements of the array. */
const retrieveNthFirstEle = (arr = [], n = 1) => {
if (arr.length === 0 || n {
if (arr.length === 0 || n = arr.length) return arr
return arr.slice(-n);
}
console.log(retrieveNthLastEle([1,2,3,4,5,6,7], 2))
most amazing question series omg this is just wow ; the explanation of bhaiya was truly amazing loved it bhaiya genuinely loved it
1:16:10 can't we just use
return arr;
can you make more video like this for javascript question it's amazing video
that's great teacher and well teaching method keep it up brother
01:13:03
For loog Ko arr.length tk chala rahy ho . Per ap bol rahy ye ik object kley code Hy... Ye bat upper sy gai.
Plz Plz Upload more videos like this
Thankyou For This Lessons Sir
Hum Jo html form banate hain usko submit karne ke baad uska data humare email par ana chahiye kaise kar shakte hain
54:35
20 more questions needed btw amazing video❤🔥
Thank you so much... amazing and excellent content...