• Search form is empty!

  • 009 TypeScript - assignment operators

    http://robertdunaway.github.io

    TypeScript code kata list

    All code kata lists

    Smiley face

    009 TypeScript - assignment operators

    Duration

    10 minutes

    Brief

    Using assignment operators (=, +=, -=, *=, /=, %=).

    For more information

    BING/GOOGLE: “TypeScript assignment operators”

    Instructions

    Get tutorial folder or the entire katas-typescript repo.
    Open the [before/*.sln] file and execute the kata.
    Feel free to execute this kata multiple times because repetition creates motor memory.

    Github

    Kata

    Create two variables of type number for working with assignment operators


    
        var a: number = 10;
        var b: number = 5;
    
    


    Output to the console the results of assignment operators (=, +=, -=, *=, /=, %=)


    
        var a: number = 10;
        var b: number = 5;
        var result: number = 0;
    
        result = a + b;
        console.log('result = a + b; // result =' + result);
    
        result += a;
        console.log('result += a; // result =' + result);
    
        result -= a;
        console.log('result -= a; // result =' + result);
    
        result *= 2;
        console.log('result *= 2; // result =' + result);
    
        result /= a;
        console.log('result /= a; // result =' + result);
    
        result %= 2;
        console.log('result %= 2; // result =' + result);
    
    


    Smiley face

    Next

    Take a few minutes and imagine more examples.

    Smiley face

    0 comments:

    Post a Comment