noknow.dev
Sign inSign up
Course overview
JavaScript Fundamentals
0 / 7 lessons0%

Getting Started

  • Hello, World!
  • Variables: let and const
  • Numbers and Math

Decisions & Loops

  • if / else — Making Decisions
  • for Loops

Functions

  • Defining Functions
  • Arrow Functions

Defining Functions

0m 00s

What are functions?

Functions are named blocks of code you can call over and over. They accept parameters and can return a value.

function greet(name) {
  return "Hello, " + name + "!"
}

console.log(greet("Alice"))  // Hello, Alice!
console.log(greet("Bob"))    // Hello, Bob!

Without return, the function returns undefined:

function noReturn() {
  console.log("I don't return anything")
}
const result = noReturn()  // undefined

Multiple parameters

function rectangle(width, height) {
  return width * height
}
console.log(rectangle(4, 5))  // 20

Your task

Write a function celsiusToFahrenheit(deg) that converts Celsius to Fahrenheit.

Formula: F = (C × 9/5) + 32

Back
javascriptCtrl+Enter to run
Output

Click "Run" to execute your code.