#26 Arrow function in JavaScript

Поділитися
Вставка
  • Опубліковано 29 вер 2024
  • Instagram : / navinreddyofficial
    Linkedin : / navinreddy20
    Discord : / discord
    More Learning :
    Java - bit.ly/3xleOA2
    Python :- bit.ly/3H0DYHx
    Django :- bit.ly/3awMaD8
    Spring Boot :- bit.ly/3aucCgB
    Spring Framework :- bit.ly/3GRfxwe
    Servlet & JSP :- bit.ly/3mh5CGz
    Hibernate Tutorial :- bit.ly/3NWAKah
    Rest API | Web Service Tutorial :- bit.ly/38RJCiy
    Git :- bit.ly/3NUHB3V
    JavaScript :- bit.ly/3mkcFys
    Kotlin :- bit.ly/3GR2DOG

КОМЕНТАРІ • 189

  • @yagneshacharya2461
    @yagneshacharya2461 2 роки тому +5

    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'

  • @_mc_hon_3219
    @_mc_hon_3219 Рік тому +32

    All these years, I haven't seen anyone explain arrow functions any better

  • @Nani-fm9dd
    @Nani-fm9dd 3 роки тому +6

    let add = (num1,num2) => num1+num2;
    let a=Math.abs(5);
    let b=Math.abs(-7);
    let result = add(a,b);
    console.log(result);

  • @AmeerMuawia-i4p
    @AmeerMuawia-i4p Місяць тому

    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);

  • @kavalikishore-xg9wt
    @kavalikishore-xg9wt Рік тому +1

    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)

  • @AlexanderAlex-x2j
    @AlexanderAlex-x2j Місяць тому

    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);

  • @salauddinsallu4209
    @salauddinsallu4209 7 місяців тому

    let addsum = (num1,num2,num3=1) => { //arrow function
    return num1 + num2 + num3
    }
    let sak = addsum(15,Math.abs(-6)); console.log(sak)

  • @asokthegreat7781
    @asokthegreat7781 2 роки тому

    let add = (num1, num2) => num2

  • @SnobbyLion
    @SnobbyLion 11 місяців тому

    GREAT explanation! Thank you!

  • @ngawangtashi326
    @ngawangtashi326 Рік тому

    let add = (n1, n2) => {
    function conv_n1(){
    if(n1

  • @srinuvasu6747
    @srinuvasu6747 2 роки тому +1

    const sumOfElements = (a,b) => {
    let result = (a > 0 && b > 0) ? a+b : `input only positive numbers`;
    console.log(result);
    }
    sumOfElements(5,2);

    • @srinuvasu6747
      @srinuvasu6747 2 роки тому

      any changes let me know brother thank you very much

  • @penuboluprudvikrishna6046
    @penuboluprudvikrishna6046 3 роки тому

    Can i do hoisting using arrow functions have a doubt sir waiting for your reply

  • @jayantamondal3242
    @jayantamondal3242 Рік тому

    let add = (num1,num2) => {
    num1 = num1 < 0 ? 0 : num1;
    num2 = num2 < 0 ? 0 : num2;
    return num1 + num2;
    }
    console.log(add(-8,8));

  • @muminulislamsayem
    @muminulislamsayem 3 роки тому +31

    let input1 = Math.abs(5);
    let input2 = Math.abs(-7);
    let sum = (num1,num2) => num1 + num2;
    let result = sum(input1,input2);
    console.log(result);

    • @MdAyub-wl4hk
      @MdAyub-wl4hk Рік тому +1

      Thank you dude
      😎

    • @pavelkundu5977
      @pavelkundu5977 9 місяців тому +5

      const add = (a,b) => Math.abs(a) + Math.abs(b)
      console.log(add(-2,-5))

  • @IMAYAVARABAN_SILAMBAM_ADIMURAI

    let t = (n1, n2) => (n1

  • @anushapatel6043
    @anushapatel6043 Рік тому +4

    // Assignment //
    const add = (num1, num2) => {
    if(num1>0 && num2>0) {
    return num1 + num2
    }
    else {
    return "negative number"
    }
    }
    let result = add(2,-3)
    console.log(result);

  • @chetan_nada
    @chetan_nada 2 роки тому +11

    We can use Math.abs(num1) + Math.abs(num2) for converting negative to positive.

  • @mithunrathod6714
    @mithunrathod6714 Рік тому +11

    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
      @prajjwalchauhan2165 Рік тому +2

      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
      @shreyashkhurud7217 Рік тому +2

      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
      @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
      @asap4064 Рік тому

      @@shreyashkhurud7217 bro you should also add another else if where both the numbers are negative

    • @Harimanideep
      @Harimanideep 10 місяців тому

      @@shreyashkhurud7217 you are also wrong man!!
      what is the use of if statements in your code!!

  • @devanshusachdev7367
    @devanshusachdev7367 3 роки тому +7

    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";

  • @heshamahmad4101
    @heshamahmad4101 Рік тому +8

    let add = (num1,num2) => Math.abs(num1) + Math.abs(num2);
    let result = add(-5,-6)
    console.log(result)

  • @parthshah1314
    @parthshah1314 3 роки тому +13

    Sir you are the inspiration and you are the one of the best guide. Keep going sir we all supports you.

  • @anushadurgam7614
    @anushadurgam7614 2 роки тому +1

    let sum =(a,b)=>{
    if (a

  • @digambarsawant1116
    @digambarsawant1116 2 роки тому +1

    let add = (num1,num2)=> (Math.abs(num1)+Math.abs(num2)) ;
    let result=add(5,-6);
    console.log(result);

  • @satheesh1290
    @satheesh1290 Рік тому +3

    let add=(n1,n2)=>
    {
    let n3=Math.abs(n1);
    let n4=Math.abs(n2);
    return n3+n4;
    }
    sum=add(4,-9);
    console.log(sum);

  • @navamshuram
    @navamshuram 2 роки тому +3

    let a1 = Math.abs(5);
    let a2 = Math.abs(-7);
    let sum = (num1,num2) => num1 + num2;
    let result = sum(a1,a2);
    console.log(result);

  • @muralivelayudam8079
    @muralivelayudam8079 2 роки тому +4

    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//

  • @ananthasri3324
    @ananthasri3324 8 місяців тому +1

    let doit = function(num1,num2){
    if(num1>=0&&num2>=0){
    console.log(num1+num2)
    }
    else{
    console.log(num1)
    }
    }
    doit(50,-5)

  • @NithinS-bm8qt
    @NithinS-bm8qt Рік тому +2

    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);

  • @alexkakhnovskyi4113
    @alexkakhnovskyi4113 10 місяців тому +1

    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

  • @barbarasanchezvasquez2242
    @barbarasanchezvasquez2242 2 роки тому +1

    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);

  • @abhishekns6802
    @abhishekns6802 2 роки тому +1

    let add = (a,b) => {
    if (a

  • @PR-kq3px
    @PR-kq3px 3 роки тому +1

    let add = (num1, num2) => num1 && num2 > 0 ? num1 + num2 : "unvalid positive num";
    console.log(add(5, 8))

  • @cordovajose5693
    @cordovajose5693 3 роки тому +7

    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.

  • @rajarajang8713
    @rajarajang8713 3 роки тому +5

    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?

    • @sivahb484
      @sivahb484 3 роки тому +2

      Let add= (num1 , num2) => Math.abs(num1) + Math.abs(num2);

    • @anandjha101
      @anandjha101 3 роки тому +4

      Instead of num1* -1 you can do -(num1);

    • @anandjha101
      @anandjha101 3 роки тому

      @@sivahb484 good way to save lines

    • @anandjha101
      @anandjha101 3 роки тому

      @@sivahb484 but you should implement your own class and in that your own abs function

  • @sombithsen177
    @sombithsen177 2 роки тому +2

    Solution to question at 5:30
    let n1=6,n2=-4
    let add=(n1,n2)=>{
    if (n1

  • @shreyashkhurud7217
    @shreyashkhurud7217 Рік тому +1

    5:07
    Answer:
    let add = (a,b) => {
    if(a

  • @kiran5432
    @kiran5432 Рік тому +1

    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)

  • @aswintr2052
    @aswintr2052 Рік тому +1

    let add=(n1,n2)=>n1+n2
    let rslt=add(-9,-6)
    console.log(rslt*-1)

  • @alinapeng8602
    @alinapeng8602 Місяць тому

    Assignment answer:
    let add = (num1, num2) => {
    if(num1

  • @kevinkiprotich9502
    @kevinkiprotich9502 2 місяці тому

    let addPositiveValuesOnly=(num1,num2)=>{
    return Math.abs(num1)+Math.abs(num2)
    }
    let result=addPositiveValuesOnly(-6,5);
    console.log(result);

  • @mohakahuja8541
    @mohakahuja8541 2 роки тому +1

    let a=4;let b=* Math.abs(-6);let add=(num1,num2)=>num1+num2;let output=add(a,b);console.log(output);

  • @rudrasaiprasad
    @rudrasaiprasad 2 місяці тому

    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.

  • @AmeerMuawia-i4p
    @AmeerMuawia-i4p Місяць тому

    let add = function(num1,num2) {
    if (num2 < 0) {

    return num1-num2;
    }
    else
    return num1+num2;
    }
    let result = add(3,8)
    console.log(result);

  • @alexissorianooo
    @alexissorianooo 2 роки тому +2

    I challenged myself to use Ternary Operator: (it is not a best practice to use nested ternary operators)
    let addNeg = (num1, num2) =>{
    return num1

  • @KishorkumarAmuluru
    @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);

  • @ManishKumar-kw7qe
    @ManishKumar-kw7qe 6 місяців тому

    let cal=(a,b)=>{
    if(a>0 && b>0){
    return a+b
    }
    else if(a>0 && b

  • @tarundhati6499
    @tarundhati6499 7 місяців тому

    function add(num1,num2)
    {
    return num1 +num2;
    }
    num1 =10;
    num2 =-17;
    let result= add(10,-17)
    if (num1

  • @ishad17-ml1si
    @ishad17-ml1si 3 місяці тому

    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

  • @elakkiyanandhini7974
    @elakkiyanandhini7974 3 місяці тому

    let addition = (num1,num2) => {
    if (num1 < 0 || num2 < 0) {
    return "Negative Numbers not accepted";
    }
    return num1 + num2;
    }
    console.log(addition(3,-2));

  • @rahulgiri1253
    @rahulgiri1253 2 роки тому

    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)

  • @VishwajeetSingh-mx8pn
    @VishwajeetSingh-mx8pn 3 місяці тому

    let add=(num1,num2)=>{
    if(num2

  • @thecreator9164
    @thecreator9164 7 місяців тому

    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)

  • @santechstudios7369
    @santechstudios7369 Рік тому

    let obj = {
    name: "John",
    sayName: () => {
    console.log(this.name);
    }
    };
    obj.sayName();
    o/p undefined WHY

  • @cs.nolife
    @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);

  • @sirojohnodilla9990
    @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)

  • @zeusheelantzu
    @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)

  • @asal3169
    @asal3169 4 місяці тому

    let add = (a,b) => {
    if (a+b < 0){
    return "the number will be less than 0"
    }
    return a+b
    }
    console.log(add(2,3));

  • @Prashuva
    @Prashuva 9 місяців тому

    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);

  • @mrgamerzyt3945
    @mrgamerzyt3945 9 місяців тому

    let a, b;
    let func1 = (a, b) => Math.abs(a) + Math.abs(b);
    console.log(func1(2, -3));

  • @jaggu7714
    @jaggu7714 11 місяців тому

    assignment
    .....
    let user = (a,b) => a + b
    a= 1
    b= 2
    let result = user(a,b)
    if(b

  • @lexsaito1189
    @lexsaito1189 Рік тому

    let add = (num1,num2,result) => result = (num1 + num2)

  • @syedareebhussain8436
    @syedareebhussain8436 Рік тому

    let sum = (num1, num2) => {
    if (num1 > 0 && num2 > 0) {
    return num1 + num1;
    } else {
    return "Negiative number not accepted";
    }
    };
    console.log(sum(5, -6));

  • @Ram-sm8pp
    @Ram-sm8pp 7 місяців тому

    const add = (num1, num2) => {
    num1

  • @Sayem-y4h
    @Sayem-y4h Рік тому

    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);

  • @codexakshay2348
    @codexakshay2348 6 місяців тому

    Assignment Question:
    let addPos = (a,b) => Math.abs(a)+Math.abs(b)
    console.log(addPos(-6,-3))

  • @joerowe9814
    @joerowe9814 Місяць тому

    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

  • @coconut4974
    @coconut4974 2 роки тому

    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");
    }

  • @siddheshbhise2056
    @siddheshbhise2056 6 місяців тому

    let sum = (a,b) => {
    a = Math.abs(a)
    b = Math.abs(b)
    return(a + b)
    }
    console.log(sum(10,-20));

  • @abroadlifestory193
    @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);

  • @rameenana
    @rameenana 9 місяців тому

    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.

  • @ngawangtashi326
    @ngawangtashi326 Рік тому

    let add = (num1, num2) => {
    if (num1>=0 && num2>=0){
    return num1 + num2;
    }
    else{
    return "number is negative";
    }
    }
    let result = add(5,-4);
    console.log(result);

  • @shrshawn
    @shrshawn 2 роки тому

    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

  • @bharathreddy2350
    @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)

  • @Ananthasri-k2r
    @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))

  • @TRENDING__NOW_
    @TRENDING__NOW_ 3 роки тому +1

    0th guy commenting here
    thanks for your videos

  • @milankbudha
    @milankbudha 3 роки тому +1

    let add = (num1,num2) => num1 + num2;
    console.log(add(5,6));//it will also work

  • @sumanmandal5952
    @sumanmandal5952 Рік тому

    let sum = (num1, num2) => {
    return num1 + num2 > 0 ? `${num1 + num2}` : "";
    };
    console.log(sum(50, 60));

  • @chandrareddykarri6277
    @chandrareddykarri6277 Рік тому

    let noneg=(num1,num2) => {
    if(num1>=0 && num2>=0){
    return num1+num2;
    }
    }
    console.log(noneg(5,-6))

  • @pooja_chowdari
    @pooja_chowdari Рік тому

    let nnum = (a,b) => (a

  • @jno1lilno
    @jno1lilno Рік тому

    my guess
    let add = (num1,num2) =>
    {
    console.log(num1+ num2);
    }
    let sum = add
    let result =sum(5,6)

  • @KanikaSri-o4b
    @KanikaSri-o4b 3 місяці тому

    let hbd = (num1,num2) =>

    num1 + num2 ;


    let ver = hbd(Math.abs(5) , Math.abs(-6));
    console.log(ver)

  • @rishabhsakhare9990
    @rishabhsakhare9990 Рік тому +2

    let add = (num1,num2) => num1 + num2
    let result = add(5,6)
    if(result>0){
    console.log("Result is Pos: " + result)
    }
    else{
    console.log("!! Please enter proper value ")
    }

  • @pavelkundu5977
    @pavelkundu5977 9 місяців тому

    const add = (a,b) => Math.abs(a) + Math.abs(b)
    console.log(add(-2,-5))

  • @mangoshala8174
    @mangoshala8174 3 роки тому +3

    Thanks, I was a bit confused with arrow functions which you made it so simple to understand.

  • @prajjwalchauhan2165
    @prajjwalchauhan2165 Рік тому

    let add = (a,b) => {
    if (a > 0 && b >0){
    return a + b
    }else {
    return ("Error");
    }
    }
    console.log(add(2,5));

  • @sonujhariya
    @sonujhariya Рік тому

    let add = (num1, num2) => {
    if (num1

  • @SaravananVeeramaniiAI
    @SaravananVeeramaniiAI Рік тому

    let add = (num1,num2) =>
    {
    if(num1

  • @ajaz4sky
    @ajaz4sky 6 місяців тому

    let sum = (num1, num2) => {
    if (num1 < 0 && num2 < 0)
    return 0;
    else if (num1 < 0)
    return num2;
    else if (num2 < 0)
    return num1;
    else
    return num1 + num2;
    }

  • @LoU3107
    @LoU3107 3 роки тому +6

    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
      @BigGus87 11 місяців тому

      its just shorthand. no actual difference

    • @BigGus87
      @BigGus87 11 місяців тому

      you can remove the return keyword even if its a regular function btw.

  • @swapnilthakar7845
    @swapnilthakar7845 3 роки тому +3

    var add = (num1,num2) => Math.abs(num1) + Math.abs(num2)

    var result = add(-10,-10)
    console.log(result) // it will print 20 .

  • @aminalwamba2007
    @aminalwamba2007 Рік тому +1

    this is amazing thank you so much

  • @vijayram5743
    @vijayram5743 11 місяців тому

    let add=function(num1,num2){
    if(num1

  • @sidharthpillai
    @sidharthpillai 2 роки тому +1

    I made the 1000th like. Thanks Navin. Having concepts simple and crisp makes it easy for daily learning.

  • @akhila294
    @akhila294 Місяць тому

    let add = (num1, num2) => (num1

  • @harishjaladi1371
    @harishjaladi1371 2 роки тому

    let exe = (num1,num2) =>
    {
    if (num1< 0 || num2 < 0)
    console.log("negatives we can't add")
    else
    console.log(num1+num2)
    }
    exe(4,-5) //negatives we can't add

  • @hrithikka3843
    @hrithikka3843 Рік тому

    Isn't it the same as lambda function from python

  • @it-095shivampatel4
    @it-095shivampatel4 11 місяців тому

    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);

  • @souravmandal3868
    @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);

  • @BLACKWIZX
    @BLACKWIZX 2 місяці тому

    i reallly dont know about arrow funtion before, i just search for arrow function in JS and got yours , I am completely understood now thanks @telusko

  • @nabanitapaul175
    @nabanitapaul175 Рік тому

    this looks similar to lambda expression in java😄