Introduction
This tutorial is intended to help developers learn how to assign a total number of owls from the sum of two numbers. It provides a step-by-step solution to the problem and a FAQ section at the end.
Step-by-Step Solution
- Gather the two numbers that will compose the sum of owls.
- Add the two numbers together to compute the sum.
- Assign the result of the sum to a variable, let’s say
numOwls
, that will contain the total number of owls.
Examples
Example 1
// assigning the total number of owls from the sum of two numbers
// variable declarations
let num1 = 2;
let num2 = 5;
let numOwls;
// variable assignments
numOwls = num1 + num2; // numOwls is now equal to 7
Example 2
// assigning the total number of owls from the sum of two numbers
// variable declarations
let num1 = 10;
let num2 = 6;
let numOwls;
// variable assignments
numOwls = num1 + num2; // numOwls is now equal to 16
FAQ
Q1: Do I need to use a variable to store the sum?
A: Yes. You need to assign the sum to a variable (in this case numOwls
) in order to store the total number of owls.
Q2: Can I use other data types besides numbers to calculate the sum?
A: No. The two numbers need to be numeric values in order to calculate the sum.