Skip to content

Peterfrontenddev1/Compound-Assignment-With-Augmented-Addition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 

Repository files navigation

Compound-Assignment-With-Augmented-Addition

In programming, it is common to use assignments to modify the contents of a variable.

Remember that everything to the right of the equals sign is evaluated first, so we can say:

                      myVar = myVar + 5;

                      to add 5 to myVar. 

Since this is such a common pattern, there are operators which do both a mathematical operation and assignment in one step.

One such operator is the += operator.

                      let myVar = 1;

                      myVar += 5;

                     console.log(myVar);

                  6 would be displayed in the console.

                    QUESTION

                  Convert the assignments for a, b, and c to use the += operator.
                  
                  let a = 3;
                  
                  let b = 17;
                  
                  let c = 12;

                  a should equal 15.

                  b should equal 26.

                  c should equal 19.

                  You should use the += operator for each variable.

                  You should not modify the code above the specified comment.

                   ANSWER
                   let a = 3;
                   let b = 17;
                   let c = 12;

                   // Only change code below this line
                    a += 12;
                    b += 9 ;
                    c += 7;

About

In programming, it is common to use assignments to modify the contents of a variable.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published