Functions in JS
Duration: 3 min
This video lesson is available to enrolled students.
Enroll to watch — UP LT Grade Assistant Teacher 2025 Computer Science Course
AI summary & chapters
AI Summary
An AI-generated summary of this video lecture.
The video lecture provides a detailed introduction to creating functions in JavaScript. The instructor utilizes a PDF document titled "Creating Functions" which outlines the fundamental syntax rules. The text explains that a function is defined using the `function` keyword, followed by a unique name and parentheses. It specifies that function names can include letters, digits, underscores, and dollar signs, adhering to the same rules as variables. The parentheses may contain parameter names separated by commas, and the code to be executed is placed inside curly brackets.
Chapters
0:00 – 2:00 00:00-02:00
The session begins with the instructor displaying a PDF slide titled "Creating Functions". The visible text details the syntax: "A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses ()." The instructor starts writing on the digital whiteboard, first scribbling some numbers like "0.03", "0x", "468", and "123 -> decimal" at the top. Then, they begin writing the word "function" and start a new example labeled "Sum(". The screen text further explains that the code to be executed is placed inside curly brackets, showing a template: `function name(parameter1, parameter2, parameter3) { // code to be executed }`.
2:00 – 2:47 02:00-02:47
The instructor continues to flesh out the code examples. They write a function named `welcome` with empty parentheses: `function welcome() { document.write("Welcome"); }`. This demonstrates a function with no parameters. Next, they write a more complex example: `function Sum(a, b, c) { let s = a+b+c; }`. This shows how to define parameters `a`, `b`, and `c` inside the parentheses and use them within the function body to calculate a sum. The instructor underlines the function call `welcome()` at the bottom, indicating how the function is invoked.
The lecture effectively bridges the gap between theoretical documentation and practical coding. It starts by establishing the rigid syntax rules found in the PDF, such as the requirement for the `function` keyword and the use of curly brackets. The instructor then transitions to a hands-on demonstration, writing out a simple text-output function and a mathematical summation function. By explicitly writing the parameters `a`, `b`, and `c` and the calculation `let s = a+b+c`, the instructor clarifies how data is passed into a function and processed effectively.