JavaScript Challenge Internship to CEO #14

JavaScript Challenge Internship to CEO #14

Task of Challenge #14/54

Print the first 10 Fibonacci numbers without recursion.

Fibonacci series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …

Solution

Explanation

We start with the creation of the for loop. We have to define the loop is running from 2 to 10 in order to get the first 10 numbers. We start with the 0 and the 1 and need 8 more.

Any number n of the Fibonacci series is created by adding up the number n-1 with the number n-2.

To get the third number, we need to have number n-1 and n-2. With n = 3, this will be number 2 and 1 of the series.

The equation is therefore:

n = n – 1 + n – 2;

Result into:

2 = 1 + 0; The 3rd number of the Fibonacci series.

Then we need to switch the n – 1 and n – 2 to the newly created ones to go further in our Fibonacci series. E voilá, do it as long as you want to get all numbers for the Fibonacci series.

The complete outcome of the console:

Follow me on Instagram and don’t miss the latest Challenge!

https://www.instagram.com/arnold.code/

Become a bullet proof developer and seek my coding adventures on Udemy

https://www.udemy.com/user/arnold-abraham-3/

Don’t miss two of my most read Medium Articles

JavaScript Challenge  Internship to CEO #13

JavaScript Challenge Internship to CEO #13

Task of Challenge #13/54

Find the maximum number in an array of numbers.

The array: [-21, 113, -34, 1, -9, 5, 99, 1, 0].

Solution

Explanation

To accomplish our task, we create a function called findMax() and pass in our array.

Inside the body, we need to create a variable referencing our found maximum value. We set the variable max to the first element of our array. Since this it the first maximum existing. We didn’t check any other so far.

The next step is to loop over the array and check if the element we are currently looking at is greater than our current max value.

If so, replace it to the newly found maximum element of array.

Once, we are done with iterating, comparing, and adding, just return the found maximum and print it to the console, and you are done!

Follow me on Instagram and don’t miss the latest Challenge!

https://www.instagram.com/arnold.code/

Become a bullet proof developer and seek my coding adventures on Udemy

https://www.udemy.com/user/arnold-abraham-3/

Don’t miss two of my most read Medium Articles

JavaScript Challenge  Internship to CEO #10

JavaScript Challenge Internship to CEO #10

Task of Challenge #10/54

 Calculate the sum of numbers in an array of numbers. The array: [1, 9, -19, 3, 5, 3, 7, 14, 91].

Solution

Explanation

To accomplish our task, we need to iterate over the array and build the sum out of each element.

Since we aren’t so experienced right now, we should not use the reduce() function. Instead, we write basic operations like this with a for loop

After the loop has finished, we print it out to the console:

Follow me on Instagram and don’t miss the latest Challenge!

https://www.instagram.com/arnold.code/

Become a bullet proof developer and seek my coding adventures on Udemy

https://www.udemy.com/user/arnold-abraham-3/

Don’t miss two of my most read Medium Articles

JavaScript Challenge  Internship to CEO #09

JavaScript Challenge Internship to CEO #09

Task of Challenge #09/54

Create a function that will convert from Fahrenheit to Celsius. Convert -38 degree Fahrenheit.

Solution

Explanation

How to convert Celsius to Fahrenheit

The temperature T in degrees Fahrenheit (°F) is equal to the temperature T in degrees Celsius (°C) times 9/5 plus 32:

T(°F) = T(°C) × 9/5 + 32

or

T(°F) = T(°C) × 1.8 + 32

Example

Convert 20 degrees Celsius to degrees Fahrenheit:

T(°F) = 20°C × 9/5 + 32 = 68 °F

To accomplish our task, we need to reverse the conversion of degrees to Fahrenheit. This means we first subtract 32 and then divide by 1.8.

This is done in the convertFahrenheitToCelsius-function.

Just return the number and print it out, and you are done!

The console prints out -38.888888888888886 when we put in the number -38.

Because this is the point where Celsius and Fahrenheit have the same amount.

Follow me on Instagram and don’t miss the latest Challenge!

https://www.instagram.com/arnold.code/

Become a bullet proof developer and seek my coding adventures on Udemy

https://www.udemy.com/user/arnold-abraham-3/

Don’t miss two of my most read Medium Articles

JavaScript Challenge  Internship to CEO #08

JavaScript Challenge Internship to CEO #08

Task of Challenge #08/54

Create a function that will convert from Celsius to Fahrenheit. Convert 0 degree Celsius.

Solution

Explanation

How to convert Celsius to Fahrenheit

The temperature T in degrees Fahrenheit (°F) is equal to the temperature T in degrees Celsius (°C) times 9/5 plus 32:

T(°F) = T(°C) × 9/5 + 32

or

T(°F) = T(°C) × 1.8 + 32

Example

Convert 20 degrees Celsius to degrees Fahrenheit:

T(°F) = 20°C × 9/5 + 32 = 68 °F

To accomplish our task, we need to return a number calculated with 1.8 and add 32 to it.

This is done in the convertCelsiusToFahrenheit-function.

Just return the number and print it out, and you are done!

The console prints out 32 when we put in the number 0.

Follow me on Instagram and don’t miss the latest Challenge!

https://www.instagram.com/arnold.code/

Become a bullet proof developer and seek my coding adventures on Udemy

https://www.udemy.com/user/arnold-abraham-3/

Don’t miss two of my most read Medium Articles