Select Page

## JavaScript Challenge Internship to CEO #09

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

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

## JavaScript Challenge Internship to CEO #08

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

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

## JavaScript Challenge Internship to CEO #07

Calculate the sum of odd numbers greater than 9 and less than 30 a `for-loop` .

## Explanation

To accomplish our task, we should remember challenge #02 because back then, the task was to print out every odd number below 99. That means we create a for loop with an increment of 2 after each iteration to get only odd numbers when starting with an odd number. In our case with 11.

Remembering challenge #05 makes us also happy again. There we had the task to create the sum of the numbers from 1 to 24. The same concept applies to this task. We add up every odd number above 9 and below 30 to a sum.

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/

## Gather more Knowledge about JavaScript?

Here are two pre-picked and high quality Medium articles for you.

## JavaScript Challenge Internship to CEO #06

Calculate 9! a `for-loop` .

## Explanation

To create the factorial of 9 we make almost the same as in challenge #05 but with a different loop body code block.

Last time we used this statement to gather the accumulated sum `sum+=i`. Knowing a bit about mathematics means you are aware of the fact that a factorial is nothing more than a chained multiplication.

So `9!` is nothing more than `9*8*7*6*5*4*3*2*1`. Together with the knowledge about `for-loops` we can draw advantages out of this by using the running index of `i` to create a factorial. To get our desired result, we iterate exact 9 times!

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

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

## Gather more Knowledge about JavaScript?

Here are two pre-picked and high quality Medium articles for you.

## JavaScript Challenge Internship to CEO #05

Calculate the sum of numbers from 1 to 24 with a `for-loop` .

## Explanation

For diversity, another challenge, but a simpler one! But that doesn’t mean you can switch off your brain 😉

We can’t just put the accumulated value of `sum` inside the loop and print it to the console. It would then end up with 24 print outs.

We have to declare and initialize the variable (and please use `let` here! You can read about the problems of declaring variables with `var`, `let`, and `const` in the featured article below. I advise you to do so!) outside of the loop in order to print it out afterward.

Declaring the variable inside the loop, then it would be initialized every iteration, instead of holding the actual accumulated value.

Furthermore, if we declared it inside the loop it would be out of our reach when we want to access it outside the loop. This is called a scope, declaring a variable inside a class/function/loop, makes it to a local variable which can’t be accessed from the outside (The article below addresses this in detail).

And this is the console output:

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

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

## Be sure to write the code write with let, var and const in JavaScript!

Here are two pre-picked and high quality Medium articles for you.