21:05 Yes, it is possible in Js to create a reverse() method that can reverse any string and it can be done by adding your custom reverse logic to String.prototype
yes, we can do that, first we have to make our function to reverse the string, the add the function to String.prototype, after this we can get that function in any where in the code.
Great content!! Can catch the intensity by putting ourself to that question Hoping to expect a shorts video/ 2-4 mins one on various questions in future :) Thanks for the Wonderful content!!!
Fella was missing a really easy implementation for the reverse. Just add a reverse function to the String prototype, and use it in the call String.prototype.reverse = function(){ return this.split("").reverse().join("") } // Then the implemntation is as easy as:_ const strRev = str.split(" ").map(s=>s.reverse()).join(" ")
What you did -> if you use the split without a gap it will break the the string into 1 alphabet by alphabet and then if you reverse that it would reverse the whole thing Instead if you split it with a gap every element would be in the split and you would get all the element one by one sepeated by a space in the array now use the map function to iterate to all the array element -> at first now you need to split every single element by value now you dont need any space to it ,this will let you reverse each element and join that when you are done and then join the previous splitted array . str.split(" ").map(x=> x.split("").reverse().join("")).join(" ")
let str = "This is JavaScript Code"; let result = str.split(" ").map((el) => el.split("").reverse().join("")).join(" "); console.log("result: ", result);
My answer to the Sum 1: let string = "This is JavaScript Mock Interview"; let newS = ""; let stringBreak = string.split(" "); for(let i of stringBreak){ var chars = i.split(''); var reversedChars = chars.reverse(); var reversedString = reversedChars.join(''); newS += " " + reversedString; } console.log(newS)
Sir, what about this approach??? const str = "Devansh Bhardwaj" const arr = str.split(" ") let result = [] for(let x of arr){ let res = x.split("").reverse().join("") result.push(res) } console.log(result.join(" "))
JavaScript, as in many other languages, strings are immutable. This means that once a string is created, its content cannot be directly modified. Therefore, any attempt to "reverse" the string will not alter the original string but instead create a new string that contains the reversed characters
function reverseString(str) { let revArray = []; let strlength = str.split(' '); for (let i = 0; i < strlength.length; i++) { let a = strlength[i].split("").reverse().join(""); revArray.push(a) } return revArray.join(" ") } console.log(reverseString("This is javascript code"))
Sir it would be better if you tell at the end of the video how much package this person deserves so we can make an idea where we stand. Although these interviews are really helpful Thank you
21:41 answer is yes function reverseString(str) { return str.split("").reverse().join(""); } const word = reverseString("this is javascriprt code"); console.log(word);
I have create word by word Reverse function without loop ; var a = 'this is javascript code';
function reverseWord(a){ var b = a.split(''); b.reverse(); b = b.join(''); b = b.split(' ').reverse().join(' '); console.log(b); return b } reverseWord(a);
const str='This is a javascript code and you have to find mac char'; const strArr=str.split(' '); let arr=[] for (let i in strArr){ arr.push(strArr[i].split('')); } let counter={}; charArr=arr.flat(); charArr.forEach(item=>{ if(counter[item]){ counter[item]+=1; } else{ counter[item]=1; } }) console.log(counter)
// // question 1 // let data = "this is javascipt code" // let result = "" // for(let ele of data.split(" ")){ // result += " " + ele.split("").reverse().join().replace(/,/g , "") // } // console.log(result) // question 2 // let data = "this is javascipt code and you to find max char" // let result = {} // for( let ele of data){ // if(ele != " ") // result[ele] = result[ele]+1 || 1 // } // console.table(result) // let maxOccurence = "" // let max = 0 // for(let ele in result){ // if(result[ele] > max){ // max = result[ele] // maxOccurence = ele // } // } // console.log(maxOccurence + " => " + max)
const str = "this is javascript code" function isReverse(str){ let newStr = str.split(" "); let result = [] for(let i =0;i=0;j--){ tempResult.push(innerStr[j]) } result.push(tempResult.join('')) } return result.join(' ') } const res = isReverse(str) console.log(res)
let text = "Hello everyone"; let arr2 = text.split(' ') console.log(arr2) let arr3 = arr2[0].toString().split('').reverse().join("") let arr4 = arr2[1].toString().split('').reverse().join("") console.log(arr3) console.log(arr4) const finalaray = arr3.concat(" "+arr4) console.log(finalaray) break everything into pieces first, then reverse it and join... easy to think easy to approach.
let str ="This is javascript Code "; let reverse=(word)=>{ let out =""; for(var i =word.length-1;i>=0 ; i--){ out+= word.charAt(i); } return out; } var revstr=""; let arrstr = str.split(" "); arrstr.forEach(function(splittedword){ revstr += reverse(splittedword)+ " "; }); console.log(revstr);
the code for this could as simple as this output = [] input_arr.map((item, index) =>{ output.push(item.split('').reverse().join('')); }); console.log(output.join(" "));
@@gaganbaghel1377 great. if you have time. lets connect at 9PM tonight ?? you can find my email on About section. I will share more details once you email me
These are not DSA-based.. they are mostly asked in companies that directly hire for a web role/intern. Mostly some startups or small service companies. Bigger companies may take DSA route
sir how can i find more interview questions like this ? I want to practice technical interview questions for JS starting from beginning to advance level, from which website you took these questions?
var reverseWords = function (s) { let res = ""; let word = ""; for (let c of s) { if (c === " ") { res += word + c; word = ""; } else { word = c + word; } } return res + word; };
//reverse the string function reverseString(str){ let tempAr=str.split(" "); let finalAr=[]; tempAr.forEach(val=>{ let stringAr=val.split(""); let string=''; stringAr.forEach(val=>{ string=val+string; }) finalAr.push(string); }) return finalAr.join(" "); } reverseString("This is JavaScript Code") // find max occuring char function findMaxOccuringChar(str){ let tempStrAr=str.split(""); let object={}; tempStrAr.forEach(val=>{ if(object.hasOwnProperty(val)) object[val]++; else object[val]=1; }) let maxChar=tempStrAr[0]; for(let i in object){ if(i!==" "&& object[i]>object[maxChar]){ maxChar=i; } } return maxChar; } findMaxOccuringChar("This is JavaScript Code and you to find max char");
let myStr = "This is javascript code and you to find max char"; let calculate = {}; function maxOccurring(str) { for (let item of str) { calculate[item] = (calculate[item] || 0) + 1; } let max = 0; let finalResults; for (let data in calculate) { if (calculate[data] > max) { max = calculate[data]; finalResults = { [data]: max, }; } } return finalResults; } console.log(maxOccurring(myStr.replaceAll(" ", "")));
Not 1 resource but you can search for any coding interview question list. They can be in different languages. Already there are too many such sites. geek for geeks/ hacker rank etc etc..
Because http module lower level hai. Express usi ko use krke API bana easy kr deta h. API banana h to express hi use kro. But HTTP is not just for API - you can make different kind of request , for that HTTP module can be used. But 99% time express hi use kroge real life mein
@@coderdost no, I haven't faced any issue regarding the same. And now your channel logo is gaining attraction bcz of its bright colours.💎 Good decision to change the logo.
But I think question is just to reverse the words in its place not the whole sentence. We can apply split to get words - but then also have to split each word again to reverse it and join
Aapne jo code likha hai Ryan Dahl bhi dar jaye yaar mere se bada coder kon hai ye...Why you are making simple things complicated .. Here is the short,readable,understandable code const str = "I am the father of Javascript programming" const splitText = str.split(' ') const reversedSplit = splitText.map((word) => { return word.split('').reverse().join('') }) const finalreverse =reversedSplit.join(" ") console.log(finalreverse)
const str="This is a Javascript code"; const strArr=str.split(' '); let newStr=""; for(let i in strArr){ newStr+=strArr[i].split('').reverse().join('') + " " } console.log(newStr)
const str = "This is JavaScript Code"; console.log( str .split(" ") .map((e) => e.split("").reverse().join("")) .join(" ") ); const str = "This is JavaScript Code and you to find max char"; const objMap = new Map(); let Max = { elem: "", Count: Number.NEGATIVE_INFINITY }; str.split("").forEach((e) => { if (e !== " ") { if (objMap.has(e)) { let val = objMap.get(e) + 1; if (val > Max.Count) Max = { elem: e, Count: val }; objMap.set(e, val); } else { objMap.set(e, 1); } } }); console.log(Max);
React 2023 MasterClass : bit.ly/3I7MYN7
React Interviews : bit.ly/3QAjAln
JavaScript Interview Shorts:
bit.ly/3XhHRQ1
React Interview Shorts :
bit.ly/3VfIrMi
More REACT Interviews - bit.ly/3QAjAln
REACT Interview Shorts :
bit.ly/3VfIrMi
JAVASCRIPT Interview Shorts:
bit.ly/3XhHRQ1
REACT JS Course (Redux & HOOKS) : bit.ly/3iMethN
Course of JAVASCRIPT : bit.ly/3u049tf
Course of Modern JS.(ES6) : bit.ly/3DvYCh6
Sir in react how to do add to cart with out using redux
21:05 Yes, it is possible in Js to create a reverse() method that can reverse any string and it can be done by adding your custom reverse logic to String.prototype
Yes I wanted same answer. Thanks
yes, we can do that, first we have to make our function to reverse the string, the add the function to String.prototype, after this we can get that function in any where in the code.
Great content!! Can catch the intensity by putting ourself to that question
Hoping to expect a shorts video/ 2-4 mins one on various questions in future :)
Thanks for the Wonderful content!!!
Yes. A video of JavaScript interviews questions is being compiled. After that may be coding questions
Fella was missing a really easy implementation for the reverse.
Just add a reverse function to the String prototype, and use it in the call
String.prototype.reverse = function(){
return this.split("").reverse().join("")
}
// Then the implemntation is as easy as:_
const strRev = str.split(" ").map(s=>s.reverse()).join(" ")
Yes possible three ways
1) str.split ("").reverse ().join ("")
2)let result =""
Inside for(let i=0;i=0;i--) {
result1 +=Str[i]
}
Cl(result1)
What you did -> if you use the split without a gap it will break the the string into 1 alphabet by alphabet and then if you reverse that it would reverse the whole thing
Instead if you split it with a gap every element would be in the split and you would get all the element one by one sepeated by a space in the array now use the map function to iterate to all the array element -> at first now you need to split every single element by value now you dont need any space to it ,this will let you reverse each element and join that when you are done and then join the previous splitted array .
str.split(" ").map(x=> x.split("").reverse().join("")).join(" ")
and I am strange that he approached the same way and still you couldnt get it
let str = "This is JavaScript Code";
let result = str.split(" ").map((el) => el.split("").reverse().join("")).join(" ");
console.log("result: ", result);
My answer to the Sum 1:
let string = "This is JavaScript Mock Interview";
let newS = "";
let stringBreak = string.split(" ");
for(let i of stringBreak){
var chars = i.split('');
var reversedChars = chars.reverse();
var reversedString = reversedChars.join('');
newS += " " + reversedString;
}
console.log(newS)
Sir, what about this approach???
const str = "Devansh Bhardwaj"
const arr = str.split(" ")
let result = []
for(let x of arr){
let res = x.split("").reverse().join("")
result.push(res)
}
console.log(result.join(" "))
JavaScript, as in many other languages, strings are immutable. This means that once a string is created, its content cannot be directly modified. Therefore, any attempt to "reverse" the string will not alter the original string but instead create a new string that contains the reversed characters
function reverseString(str) {
let revArray = [];
let strlength = str.split(' ');
for (let i = 0; i < strlength.length; i++) {
let a = strlength[i].split("").reverse().join("");
revArray.push(a)
}
return revArray.join(" ")
}
console.log(reverseString("This is javascript code"))
1st :
const rev = (str)=> {
let lineRev = inp.split(" ").reverse()
return lineRev.map(word=> word.split('').reverse().join("")).toString()
}
const string="This is Javascript code"
let str1=string.split(""). reverse ().join("")
let str2=str1.split(" "). reverse ().join(" ")
Console.log(str2)
Simple solution is
const a = "This is Javascript Code";
const reversedWords = a.split(' ').map(word => word.split('').reverse().join('')).join(' ');
console.log(reversedWords);
//output - "sihT si tpircsavaJ edoC"
great content sir thank u for making this type of videos
2nd:
const maxChar = (str) => {
let arr = str.split("");
let count = 0;
let res = "";
arr.forEach((ch) => {
let innercount = 0;
arr.forEach((el) => {
if (el == ch) {
innercount += 1;
}
});
if (innercount > count) {
count = innercount;
res = ch;
}
});
return res;
};
Sir it would be better if you tell at the end of the video how much package this person deserves so we can make an idea where we stand.
Although these interviews are really helpful
Thank you
We will optimise soon👍🏻
const maxWordCount=(str)=>{
const word = str.split(' ')
const maxArr = word.map((e)=>e.split('').length)
const output = Math.max(...maxArr)
return output
}
console.log(maxWordCount("this is javascript code"))
21:41 answer is yes
function reverseString(str) {
return str.split("").reverse().join("");
}
const word = reverseString("this is javascriprt code");
console.log(word);
let str="mabujani"
let res=[]
for(let i=0; itimes)
{
times=res[char]
max=char
}
}
console.log(times,max)
After solving the many dsa question this question look likes the 1+1
const str = "This is Javascript Code!";
function reverseString(str) {
const splittedStr = str.split(' ');
let reversedStr = "";
for(let elem of splittedStr) {
reversedStr += elem.split('').reverse().join('') + ' ';
}
return reversedStr;
}
console.log(reverseString(str));
I have create word by word Reverse function without loop ;
var a = 'this is javascript code';
function reverseWord(a){
var b = a.split('');
b.reverse();
b = b.join('');
b = b.split(' ').reverse().join(' ');
console.log(b);
return b
}
reverseWord(a);
Please add some difficult questions for person having more than 4+ years of experience.
const str='This is a javascript code and you have to find mac char';
const strArr=str.split(' ');
let arr=[]
for (let i in strArr){
arr.push(strArr[i].split(''));
}
let counter={};
charArr=arr.flat();
charArr.forEach(item=>{
if(counter[item]){
counter[item]+=1;
}
else{
counter[item]=1;
}
})
console.log(counter)
const str = "this is javascript code";
let ans = str.split(" ").map((elm)=>elm.split('').reverse().join('')).join(" ");
console.log(ans);
const A = 'This is javascript code';
const R = [];
A.split(' ').forEach(element => {
R.push(element.split('').reverse().join(''));
});
console.log(R.join(' '));
const str = "This is JavaScript Code";
const revStr = str.split(' ').map((word) => word.split('').reverse().join('')).join(' ');
console.log(revStr);
ques1:
const str="This is JavaScript"
String.prototype.reverse=function(){
const newStr=str.split('').reverse().join('').split(' ').reverse().join(' ');
console.log(newStr)
}
str.reverse()
reverse function is apply on the array only, not string or number
// // question 1
// let data = "this is javascipt code"
// let result = ""
// for(let ele of data.split(" ")){
// result += " " + ele.split("").reverse().join().replace(/,/g , "")
// }
// console.log(result)
// question 2
// let data = "this is javascipt code and you to find max char"
// let result = {}
// for( let ele of data){
// if(ele != " ")
// result[ele] = result[ele]+1 || 1
// }
// console.table(result)
// let maxOccurence = ""
// let max = 0
// for(let ele in result){
// if(result[ele] > max){
// max = result[ele]
// maxOccurence = ele
// }
// }
// console.log(maxOccurence + " => " + max)
for question 1 , this is enough:
const str = "This is JavaScript Code"
console.log(
str
.split(" ")
.map(word => word.split("").reverse().join(""))
.join(" ")
)
Sir, great content, inspirational
const str = "this is javascript code"
function isReverse(str){
let newStr = str.split(" ");
let result = []
for(let i =0;i=0;j--){
tempResult.push(innerStr[j])
}
result.push(tempResult.join(''))
}
return result.join(' ')
}
const res = isReverse(str)
console.log(res)
let text = "Hello everyone";
let arr2 = text.split(' ')
console.log(arr2)
let arr3 = arr2[0].toString().split('').reverse().join("")
let arr4 = arr2[1].toString().split('').reverse().join("")
console.log(arr3)
console.log(arr4)
const finalaray = arr3.concat(" "+arr4)
console.log(finalaray)
break everything into pieces first, then reverse it and join... easy to think easy to approach.
Sir I also want to give a mock coding interview like this.
form is available on community post
let str ="This is javascript Code ";
let reverse=(word)=>{
let out ="";
for(var i =word.length-1;i>=0 ; i--){
out+= word.charAt(i);
}
return out;
}
var revstr="";
let arrstr = str.split(" ");
arrstr.forEach(function(splittedword){
revstr += reverse(splittedword)+ " ";
});
console.log(revstr);
the code for this could as simple as this
output = []
input_arr.map((item, index) =>{
output.push(item.split('').reverse().join(''));
});
console.log(output.join(" "));
in the last problem you should have removed the empty string from the array. Otherwise, it would always give empty string has the largest count
That's the developers problem to figure out not the interviewer
str.split(" ").map((i) => i.split("").reverse().join("")).join(" "); For the First Question : Reversing String Word wise not whole at once
come-up with single line approach
let result = str.split('').reverse().join('').split(' ').reverse().join(" ")
console.log(result)
good one
We can create one prototype for it like , String.prototype.reversestring = function ()
{
///// Your logic
And return string
}
prefect
yes, we can using prototype
Thanks For This Video
Add Custom function with String prototype
Yes. That answer we needed
As strings are immutable in javascript so it is not possible to mutate the some string by making a reverse function
yes. we can't reverse original. but can return a Copy using ProtoType methods.
@@coderdost i like what you make around web development and js want to work with you
@@gaganbaghel1377 great. if you have time. lets connect at 9PM tonight ?? you can find my email on About section. I will share more details once you email me
@@coderdost ok we can but i am currently having aligned interviews for a week can we connect after that i will mail you as soon as possible
sure
Great Content. Love from Pakistan
let reverse=" "
let text = "This Is Javascript Code";
const arr = text.split(" ").map((item)=>{
for(let i=item.length-1;i>=0;i--){
reverse+=item[i]
}
reverse+=" "
return reverse
})
console.log(reverse)
Sir i have a question are these mock interviews for the companies which prefer dsa students or the development companies
These are not DSA-based.. they are mostly asked in companies that directly hire for a web role/intern. Mostly some startups or small service companies. Bigger companies may take DSA route
let arr= str.split(' ')
let out= new Array();
for(let i=0;i
const message = "The rain in SPAIN stays mainly in the plain"
const result=message.toLocaleLowerCase().split(" ").join("")
console.log(result)
const maxcount=(result)=>{
const maxchar=[];
for(let i=0;i val === result[i]).length
maxchar.push(char)
}
return Math.max.apply(null, maxchar);
}
console.log(maxcount(result.split("")))
21:31 Prototype Approch Will Help this scenario.
sir how can i find more interview questions like this ? I want to practice technical interview questions for JS starting from beginning to advance level, from which website you took these questions?
There is not a particular website for JS which I know. You can try - geeks for geeks they have good questions for coding- independent of languages..
Great
var reverseWords = function (s) {
let res = "";
let word = "";
for (let c of s) {
if (c === " ") {
res += word + c;
word = "";
} else {
word = c + word;
}
}
return res + word;
};
this reverses whole string (every character), not the word order.
//reverse the string
function reverseString(str){
let tempAr=str.split(" ");
let finalAr=[];
tempAr.forEach(val=>{
let stringAr=val.split("");
let string='';
stringAr.forEach(val=>{
string=val+string;
})
finalAr.push(string);
})
return finalAr.join(" ");
}
reverseString("This is JavaScript Code")
// find max occuring char
function findMaxOccuringChar(str){
let tempStrAr=str.split("");
let object={};
tempStrAr.forEach(val=>{
if(object.hasOwnProperty(val))
object[val]++;
else
object[val]=1;
})
let maxChar=tempStrAr[0];
for(let i in object){
if(i!==" "&& object[i]>object[maxChar]){
maxChar=i;
}
}
return maxChar;
}
findMaxOccuringChar("This is JavaScript Code and you to find max char");
let myStr = "This is javascript code and you to find max char";
let calculate = {};
function maxOccurring(str) {
for (let item of str) {
calculate[item] = (calculate[item] || 0) + 1;
}
let max = 0;
let finalResults;
for (let data in calculate) {
if (calculate[data] > max) {
max = calculate[data];
finalResults = {
[data]: max,
};
}
}
return finalResults;
}
console.log(maxOccurring(myStr.replaceAll(" ", "")));
const str = "This is JavaScript"
const stringReversalByWords = (str) => {
const newStr = []
str.split(" ").map((elem) =>{
return newStr.push(elem.split("").reverse().join(""))
})
console.log(newStr.join(" "))
}
stringReversalByWords(str)
Are there any resource/website where we can find this type of questions of this level?
Not 1 resource but you can search for any coding interview question list. They can be in different languages. Already there are too many such sites. geek for geeks/ hacker rank etc etc..
sir 1 Q tha jab express se routing kar skate hai tou node me HTTP or URL module Ku banye video bana ke bata dijiye ga
Because http module lower level hai. Express usi ko use krke API bana easy kr deta h. API banana h to express hi use kro. But HTTP is not just for API - you can make different kind of request , for that HTTP module can be used. But 99% time express hi use kroge real life mein
@@coderdost thanks sir
Reverse method not support in str
Hello sir.... Kya interview me jinki langwadge english hogi vhi interview de skta hai..?
Most companies take interviews in English only. and thats why we used english.
Aapne channel logo change kr dia?
Mtlb doosre colour ka laga dia..
Yes just for dark mode.any issue you faced after the change ?
@@coderdost no, I haven't faced any issue regarding the same.
And now your channel logo is gaining attraction bcz of its bright colours.💎
Good decision to change the logo.
Can't we apply the split method first and then print the array in reverse order
But I think question is just to reverse the words in its place not the whole sentence. We can apply split to get words - but then also have to split each word again to reverse it and join
@@coderdost got it
This interview is for which level of experience or this guy is a fresher?
He had some experience in IT but not from CS background
const ReverseString = (str) => {
const s = str.split(" ");
let dats = [];
for (let i = 0; i < s.length; i++) {
let dat = s[i].split("");
dats.push(dat.reverse().join(""));
}
const rev = dats.join(" ");
return rev;
};
Here, we can learn how not to do things , more than how to do things, it's still okay we getting something from this.
Yeah. Main objective is to put yourself in that situation. Once you are used to such situations- stress of interview is lower when its is in real
js coding round ka playlist ka link dedo !!
ruclips.net/p/PL2PkZdv6p7ZniAiKp2TCtJKFna6MCweYr
When will the next video come?
Next on thursday
chalo kal hi dal dete hain
i wish u as my interviwer
let str = "NodeJS is a javascript runtime";
const reverseWord = (str) => {
let arrStr = str.split(" ");
console.log(arrStr);
let newArrStr = arrStr.map((item) => {
return item.split("").reverse().join("");
});
return newArrStr.join(" ");
}
let res = reverseWord(str);
console.log(res);
Aapne jo code likha hai Ryan Dahl bhi dar jaye yaar mere se bada coder kon hai ye...Why you are making simple things complicated .. Here is the short,readable,understandable code const str = "I am the father of Javascript programming"
const splitText = str.split(' ')
const reversedSplit = splitText.map((word) => {
return word.split('').reverse().join('')
})
const finalreverse =reversedSplit.join(" ")
console.log(finalreverse)
Candidate was live , so sometimes pressure makes things complex
It's painful to watch
Yes. But if you can solve faster. Its okay
In life not every thing can be fast. So do interview and mocks
const str="This is a Javascript code";
const strArr=str.split(' ');
let newStr="";
for(let i in strArr){
newStr+=strArr[i].split('').reverse().join('') + " "
}
console.log(newStr)
let wordArray=word.split(" ")
const reverseWord=wordArray.map(item=>item.split("").reverse().join(""))
console.log(reverseWord.join(" "))
const str = "harshit rajput"
const arr = str.split('')
// console.log(arr)
function h(arr){
let l =0;
let r=0;
let n = 0;
for(;r
const str = "This is JavaScript Code";
console.log(
str
.split(" ")
.map((e) => e.split("").reverse().join(""))
.join(" ")
);
const str = "This is JavaScript Code and you to find max char";
const objMap = new Map();
let Max = {
elem: "",
Count: Number.NEGATIVE_INFINITY
};
str.split("").forEach((e) => {
if (e !== " ") {
if (objMap.has(e)) {
let val = objMap.get(e) + 1;
if (val > Max.Count) Max = { elem: e, Count: val };
objMap.set(e, val);
} else {
objMap.set(e, 1);
}
}
});
console.log(Max);