SimplyJavaScript-Logo SimplyJavaScript-Logo
  • Home
  • Tutorials
  • Syllabus
  • Roadmap
  • Guidelines
  • Interview
  • Exercises
  • Quizzes
  • Practice
    • Projects
    • Playground
    • Games
JavaScript Exercises
  • Basic Knowledge
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
    4. Exercise-4
    5. Exercise-5
  • Variables & Identifiers
    1. Exercise-1
    2. Exercise-2
  • Data Types
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
    4. Exercise-4
  • Operators
    1. Exercise-1
    2. Exercise-2
  • Conditional Statements
    1. Exercise-1
    2. Exercise-2
  • Loops & Switch
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
    4. Exercise-4
    5. Exercise-5
  • Strings
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
    4. Exercise-4
    5. Exercise-5
  • Scopes
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
    4. Exercise-4
    5. Exercise-5
  • Functions
    1. Exercise-1
  • Arrays
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
  • Objects
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
  • DOM
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
  • Functions Advanced
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
  • Debugging
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
  • Numbers
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
  • Set
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
  • Map
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
  • Destructuring
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
  • Error Handling
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3
  • Promises
    1. Exercise-1
    2. Exercise-2
    3. Exercise-3

JavaScript Functions - Exercise 1

Question 1: What is a function in JavaScript?

A function is a reusable block of code that performs a specific task. Functions are defined using the function keyword (or as arrow functions) and can accept parameters and return a value.

function greet(name) {
  return "Hello, " + name + "!";
}
console.log(greet("World")); // Hello, World!
SimplyJavaScript Logo SimplyJavaScript Logo

Ultimate JavaScript Learning Destination

simplyjavascriptdev@gmail.com
Study
  • Tutorials
  • Coding Guidelines
  • Glossary
  • Projects
  • Exercises
  • Quizzes
Explore
  • Interview Questions
  • JS Games
  • Learning Roadmap
  • JS Playground
  • Syllabus
Company
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms of Use

SimplyJavaScript is designed for learning and training. Examples may be simplified to improve readability. Tutorials, references, and examples are regularly reviewed to minimize errors, but we cannot guarantee full correctness of all content. By using SimplyJavaScript, you agree to our Terms of Use, Privacy Policy, and use of cookies.

© 2026 SimplyJavaScript. All rights reserved.  |  Privacy Policy  |  Terms of Use