i took paid course from other but i cant understood arrow functions there , so i came here 😂😂😂,,, atlast we all have to come to 'mentors of all mentors'
@cordovajose56933 жыл бұрын
This was easy for me because I saw your Java Lambda videos some time ago. You did a great job explaining how an anonymoys class can be converted into a lambda expression.
@mithunrathod6714 Жыл бұрын
time stamp: 5:10 // Assignment => let addition = function(num1, num2) { if (num1 > -1 && num2>-1){ console.log(num1 + num2); } else{ console.log("One of those number is negative"); } } addition(1400, 56); Output -- 1456
@prajjwalchauhan2165 Жыл бұрын
you didn't mentioned return statement bro! her's the ans:- let add = (a,b) => { if (a > 0 && b >0){ return a + b }else { return ("Error"); } } console.log(add(2,5));
@shreyashkhurud7217 Жыл бұрын
You are both wrong! he told to add the numbers even if one of them or both are negative! Here's the right answer let add = (a,b) => { if(a
@thequantum-plator Жыл бұрын
@@shreyashkhurud7217 lol no, he said add the numbers only if they are positive. Those 2 commentators understood the question right. Listen carefully at 5:27
@asap4064 Жыл бұрын
@@shreyashkhurud7217 bro you should also add another else if where both the numbers are negative
@Harimanideep Жыл бұрын
@@shreyashkhurud7217 you are also wrong man!! what is the use of if statements in your code!!
@little_things_313 ай бұрын
let add = (num1, num2) => (num1
@devanshusachdev73673 жыл бұрын
Enjoying your course a lot! It's great to be a part of your alienArmy👽 Here's my solution for the assignment question: let func = (num1, num2) => (num1>=0 && num2>=0)?num1+num2:"positive numbers only";
@chetan_nada3 жыл бұрын
We can use Math.abs(num1) + Math.abs(num2) for converting negative to positive.
@parthshah13143 жыл бұрын
Sir you are the inspiration and you are the one of the best guide. Keep going sir we all supports you.
@navamshuram2 жыл бұрын
let a1 = Math.abs(5); let a2 = Math.abs(-7); let sum = (num1,num2) => num1 + num2; let result = sum(a1,a2); console.log(result);
@satheesh1290 Жыл бұрын
let add=(n1,n2)=> { let n3=Math.abs(n1); let n4=Math.abs(n2); return n3+n4; } sum=add(4,-9); console.log(sum);
@NithinS-bm8qt2 жыл бұрын
const add = (num1, num2) => { const condition1 = Math.sign(num1); const condition2 = Math.sign(num2); if ((condition1 && condition2) === 1) return num1+num2 else return ('given num is zero or negative') } let result = add(1,9); console.log(result);
@rohithyarramsetty5600 Жыл бұрын
What's the validation here? *if ((condition1 && condition2) === 1)*
@sombithsen1772 жыл бұрын
Solution to question at 5:30 let n1=6,n2=-4 let add=(n1,n2)=>{ if (n1
@ananthasri332410 ай бұрын
let doit = function(num1,num2){ if(num1>=0&&num2>=0){ console.log(num1+num2) } else{ console.log(num1) } } doit(50,-5)
@heshamahmad4101 Жыл бұрын
let add = (num1,num2) => Math.abs(num1) + Math.abs(num2); let result = add(-5,-6) console.log(result)
@anushadurgam76142 жыл бұрын
let sum =(a,b)=>{ if (a
@Nani-fm9dd3 жыл бұрын
let add = (num1,num2) => num1+num2; let a=Math.abs(5); let b=Math.abs(-7); let result = add(a,b); console.log(result);
@joerowe98143 ай бұрын
great use of comments in the lower half of the screen. Nice pace. Not too long. I have watched a lot of bad videos trying to teach fat arrow functions and this is the best Thank you. @Telusko
@it-095shivampatel4 Жыл бұрын
let n1=+prompt("enter first num"); let n2=+prompt("enter second num"); let sum =add(n1,n2); let add = (n1,n2)=>Math.abs(n1)+Math.abs(n2); console.log(sum);
@mohakahuja85412 жыл бұрын
let a=4;let b=* Math.abs(-6);let add=(num1,num2)=>num1+num2;let output=add(a,b);console.log(output);
@mangoshala81743 жыл бұрын
Thanks, I was a bit confused with arrow functions which you made it so simple to understand.
@andreap97562 жыл бұрын
Right! For me too.
@digambarsawant11162 жыл бұрын
let add = (num1,num2)=> (Math.abs(num1)+Math.abs(num2)) ; let result=add(5,-6); console.log(result);
@alexkakhnovskyi4113 Жыл бұрын
he didn't mention one of the main features of the arrow functions. Arrow functions do not bind their own "this", instead, they inherit the one from the parent scope
@sumanth1846Ай бұрын
Thank you so much sir , clear explanation love from telugu people
@alinapeng86023 ай бұрын
Assignment answer: let add = (num1, num2) => { if(num1
@AmeerMuawia-i4p3 ай бұрын
5:10 let add = function(num1,num2) { if (num2 < 0) { let positive_coverter = -1; num2 = positive_coverter*num2; return num1+num2; } else return num1+num2; } let result = add(3,-8) console.log(result);
@rahulgiri12532 жыл бұрын
we can do different way- 1st way without inbuiled func:- let add=(num1,num2) => num1+(num2*-1); let result=add(5,-6) console.log(result) 2nd let add=(num1,num2) => num1+(-num2); let result=add(5,-6) console.log(result) 3rd way with inbuiled let add=(num1,num2) => num1+num2; let num1=Math.abs(5) let num2=Math.abs(-6) let result=add(num1,num2) console.log(result)
@sidharthpillai2 жыл бұрын
I made the 1000th like. Thanks Navin. Having concepts simple and crisp makes it easy for daily learning.
@thecreator91649 ай бұрын
last question answer: let add=(num1,num2)=>{ if (num1>0 && num2>0) return num1+num2 else return "Only positive numbers are allowed as input" } let result=add(3,-4) console.log(result)
@tarundhati64999 ай бұрын
function add(num1,num2) { return num1 +num2; } num1 =10; num2 =-17; let result= add(10,-17) if (num1
@kavalikishore-xg9wt Жыл бұрын
let sum=(num1,num2)=>{ result=num1+num2; if (result>0){ console.log(`value is ${result} +ve`); }else{ console.log('enter correct value'); } } sum(5,6)
let ans = (a,b) => { let num1 = Math.abs(a) let num2 = Math.abs(b) return num1 + num2; } console.log(ans(-78,22)); // 100 is the output
@jaggu7714 Жыл бұрын
assignment ..... let user = (a,b) => a + b a= 1 b= 2 let result = user(a,b) if(b
@Prashuva11 ай бұрын
let add = (num1, num2) => { let n1 = Math.abs(num1); let n2 = Math.abs(num2); return n1 +n2; } let result =add(1,-14); console.log(result);
@andreap97562 жыл бұрын
After all this time, I can say I understand what the hell a arrow function is now!!!! Dude thanks :)
@bharathreddy2350 Жыл бұрын
let n1=Math.abs(3) let n2=Math.abs(-4) let add=(n1,n2)=>n1+n2; let R=add(n1,n2) console.log(R)
@kiran5432 Жыл бұрын
let add=(a,b)=>{ if(a>=0&&b>=0) return a+b else console.log("one of the input is negative") } let result=add(2,-3) console.log(result)
@pradlife79873 ай бұрын
As usual - very well explained
@barbarasanchezvasquez22422 жыл бұрын
My answer of the exercise at 5:06: //By @iamsanbarb let add = (num1, num2) => num1 + num2; let result = add(Math.abs(5),Math.abs(-6)); console.log(result);
@abroadlifestory193 Жыл бұрын
let a = Math.abs(6) let b = Math.abs(-7) let sum = (num1,num2)=> (num1+num2) let result = sum (a,b) console.log(result);
@rudrasaiprasad4 ай бұрын
let add = (n1, n2) => { if(n1 / (n1 * (-1)) == -1 || n2 / (n2 * (-1)) == -1) { return "-ve number alert" }else{ return n1+n2; } }; console.log(add(5,6)); this will give you the always positive output.
@souravmandal3868 Жыл бұрын
The code for the assignment is: let add = (num1, num2) => { if (num1 > 0 && num2 > 0) return num1 + num2; else return "Can't add negative numbers"; } const prompt = require("prompt-sync") ({sigint: true}); let num1 = Number.parseInt (prompt ("Enter the first number: ")); let num2 = Number.parseInt (prompt ("Enter the second number: ")); let ans = add (num1, num2); console.log (ans);
@alexissorianooo2 жыл бұрын
I challenged myself to use Ternary Operator: (it is not a best practice to use nested ternary operators) let addNeg = (num1, num2) =>{ return num1
@LoU31073 жыл бұрын
Whats the benefit in this case using an arrow function instead of function expression? For now, I see the difference is that you can save the brackets if its only 1 statement and you can remove the return keyword.
@BigGus87 Жыл бұрын
its just shorthand. no actual difference
@BigGus87 Жыл бұрын
you can remove the return keyword even if its a regular function btw.
@mrgamerzyt394511 ай бұрын
let a, b; let func1 = (a, b) => Math.abs(a) + Math.abs(b); console.log(func1(2, -3));
@AlexanderAlex-x2j3 ай бұрын
7:31 let add = (num1, num2)=> { if (num1 > 0 && num2 >0) return num1 + num2 ; else console.log("Please add positive numbers only"); // return undefined; } let result = add (5,-6); console.log(result);
@KanikaSri-o4b5 ай бұрын
let hbd = (num1,num2) => num1 + num2 ; let ver = hbd(Math.abs(5) , Math.abs(-6)); console.log(ver)
@codexakshay23488 ай бұрын
Assignment Question: let addPos = (a,b) => Math.abs(a)+Math.abs(b) console.log(addPos(-6,-3))
@muralivelayudam80792 жыл бұрын
let sum = function (n1, n2) { var result = n1 + n2; if (result > 0) { console.log("+VE"); } else if (result < 0) { console.log("-VE"); } }; sum(5, -6); //MuraliVelyudam//
@satheesh1290 Жыл бұрын
what if (-5,6)
@milankbudha3 жыл бұрын
let add = (num1,num2) => num1 + num2; console.log(add(5,6));//it will also work
@amirhafidz54702 жыл бұрын
let add = (num1,num2) => Math.abs(num1)+Math.abs(num2) console.log(add(6,-5))
@sonujhariya Жыл бұрын
let add = (num1, num2) => { if (num1
@salauddinsallu42099 ай бұрын
let addsum = (num1,num2,num3=1) => { //arrow function return num1 + num2 + num3 } let sak = addsum(15,Math.abs(-6)); console.log(sak)
@aswintr20522 жыл бұрын
let add=(n1,n2)=>n1+n2 let rslt=add(-9,-6) console.log(rslt*-1)
@asokthegreat77812 жыл бұрын
let add = (num1, num2) => num2
@cs.nolife Жыл бұрын
let add = (num1, num2) => { return convertToPositive(num1) + convertToPositive(num2); } let convertToPositive = (num) => { return num > 0 ? num : num * -1; } let sum = add(10, -5); console.log(sum);
@siddheshbhise20568 ай бұрын
let sum = (a,b) => { a = Math.abs(a) b = Math.abs(b) return(a + b) } console.log(sum(10,-20));
@kevinkiprotich95024 ай бұрын
let addPositiveValuesOnly=(num1,num2)=>{ return Math.abs(num1)+Math.abs(num2) } let result=addPositiveValuesOnly(-6,5); console.log(result);
@zeusheelantzu Жыл бұрын
1. let add = (num,num1) => { if(num && num1 >= 0) { let result = num + num1 console.log(result) }else { console.log('Stay positive..') } } add(5,-6) 2. let add = (num,num1) => { if(num < 0) { num = Math.abs(num) }if(num1 < 0) { num1 = Math.abs(num1) } return num + num1 } let result = add(5,6) console.log(result) 3. let add = (num, num1) => num&&num1 >= 0 ? num+num1 : "Stay positive.." let result = add(5,-6) console.log(result)
@InfoAnishGarg3 жыл бұрын
So useful, i always use this. Just love it 💕
@coconut49742 жыл бұрын
let negetive = (num1,num2) => { return sum } a = 9920 b= 50 sum = a+b if (a > 0 && b > 0) { console.log(negetive(sum)); } else { console.log("dont allow negative numbers"); }
@asal31696 ай бұрын
let add = (a,b) => { if (a+b < 0){ return "the number will be less than 0" } return a+b } console.log(add(2,3));
@rameenana11 ай бұрын
Nice of you to make a video to help others. Though you seem to understand how to write an arrow function, I don’t think you understand the purpose of it. Use a Class in combination with .this That’ll help your audience understand the purpose of the code and then why you write it will make sense. And dude, don’t say things like “I know it doesn’t make sense but…” You can say that about an advanced topic you’ll cover in the future but you can’t say that about the core topic you’re teaching. Hope this helps. Good luck mate.
@tektektuktuk4086 Жыл бұрын
Such a good explanation
@jno1lilno2 жыл бұрын
so can you use a arrow function with more than one statement ? and if so do you still have to include the curly brackets?
@smrpkrl Жыл бұрын
yeah we can use arrow fucntion if it has multiple statements also..it's just that if you are using arrow function and your arrow function has only one statement, you dont need to use curly brackets and if your one statement arrow function returns something, you dont need to even write "return".
@pooja_chowdari Жыл бұрын
not only in arrow functions whenever you want to group multiple statements you have to use curly braces
@rajarajang87133 жыл бұрын
let add = function(num1, num2) { num1 = (num1 < 0) ? num1 * -1 : num1; num2 = (num2 < 0) ? num2 * -1 : num2; return num1 + num2; } let result = add(5, -6); console.log(result); is that right or wrong?
@sivahb4843 жыл бұрын
Let add= (num1 , num2) => Math.abs(num1) + Math.abs(num2);
@anandjha1013 жыл бұрын
Instead of num1* -1 you can do -(num1);
@anandjha1013 жыл бұрын
@@sivahb484 good way to save lines
@anandjha1013 жыл бұрын
@@sivahb484 but you should implement your own class and in that your own abs function
@SnobbyLion Жыл бұрын
GREAT explanation! Thank you!
@elakkiyanandhini79745 ай бұрын
let addition = (num1,num2) => { if (num1 < 0 || num2 < 0) { return "Negative Numbers not accepted"; } return num1 + num2; } console.log(addition(3,-2));
@sirojohnodilla9990 Жыл бұрын
let add = (num1,num2) => { if(num1 < 0 || num2 < 0){ console.log(`Negative Number detected!`) } else{ let result = Number(num1) + Number(num2) console.log(`The result is ${result}`) } } let num1 = prompt("Enter first number:") let num2 = prompt("Enter second number:") add(num1,num2)
@MrTranimation Жыл бұрын
Great tutorials man!
@jno1lilno2 жыл бұрын
my guess let add = (num1,num2) => { console.log(num1+ num2); } let sum = add let result =sum(5,6)
@AmeerMuawia-i4p3 ай бұрын
let add = function(num1,num2) { if (num2 < 0) { return num1-num2; } else return num1+num2; } let result = add(3,8) console.log(result);
@Ram-sm8pp9 ай бұрын
const add = (num1, num2) => { num1
@juliettemiso1521Ай бұрын
Returns the sum if both numbers are positive const add = (x , y) =>{ if ( x > 0 && y > 0 ){ return x + y ; } else{ return "please enter positive numbers" ; } } console.log(add(5 , 6));
@SaravananVeeramaniiAI Жыл бұрын
let add = (num1,num2) => { if(num1
@VishwajeetSingh-mx8pn5 ай бұрын
let add=(num1,num2)=>{ if(num2
@aminalwamba2007 Жыл бұрын
this is amazing thank you so much
@Mohamed-bu1yt Жыл бұрын
This video is very useful and understandable thanks
@DannyH77 Жыл бұрын
wow so much cleaner . thank you
@ngawangtashi326 Жыл бұрын
let add = (n1, n2) => { function conv_n1(){ if(n1
@Ananthasri-k2r Жыл бұрын
let add = (num1,num2) =>{ if(num1 > 0 && num2 > 0 ){ return num1 + num2 } else { return 'Entered number is negative number you need to change' } } console.log(add(5,-1))
@sivakishore58292 жыл бұрын
let sum = (num1,num2) => num1 +(-(num2)); let result = sum(5,-5); console.log(result); VM1474:3 10
@eheper2 жыл бұрын
Nice explanation.
@KishorkumarAmuluru Жыл бұрын
Using if else operator ------------------------------------ let sum = (number1, number2) => { if(number1 > 0 && number2 > 0) return(number1 + number2); else console.log("One of those number is negative"); } let result = sum(8,-2); console.log(result); Using Ternary operator ------------------------------------ let sum = (number1, number2) => { return (number1 > 0 && number2 > 0) ? (number1 + number2) : "One of those number is negative"; } let result = sum(8,12); console.log(result);
function numbers(num1, num2) { if (num1 > 0 && num2 > 0) { return num1 + num2; } else { console.log("The number is negetive"); } } let addition = numbers(5, 6); console.log(addition);
@ganeshjaggineni4097 Жыл бұрын
NICE SUPER EXCELLENT MOTIVATED
@saritharamagiri1634 Жыл бұрын
Hi Naveen, please make videos on reactJS it would be helpful.
@TheTechCritic113 жыл бұрын
SIR IS MACBOOK PREFERED FOR PROGRAMMING OVER WINDOWS?
@dipersonmaharjan20153 жыл бұрын
you can program on both but in my opinion because majority of the population has windows youtubers or others shows programming in windows.
@shrshawn2 жыл бұрын
let sum = (num1,num2) => (num1 >= 0 && num2 >=0) ? num1 + num2 : (num1 >=0 ? num1 : num2); is this the answer? my logic is- only add nos if both are non negative. else return any no which is non negative
@anandjha1013 жыл бұрын
Very easy questions for me because I have learned data structure and algorithms But I have learned my first programming language from you🥰🥰