0% found this document useful (0 votes)
3 views10 pages

Javascript Function

The document outlines a User Interface Design course syllabus focusing on JavaScript functions and their applications in web development. It explains key concepts such as function parameters, invocation, return values, and local variables. Additionally, it includes exercises for students to practice creating functions that perform specific tasks.

Uploaded by

ramanathanngl2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views10 pages

Javascript Function

The document outlines a User Interface Design course syllabus focusing on JavaScript functions and their applications in web development. It explains key concepts such as function parameters, invocation, return values, and local variables. Additionally, it includes exercises for students to practice creating functions that perform specific tasks.

Uploaded by

ramanathanngl2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

UID

User Interface Design


23CSE113
User Interface
Design
Prepared by,
Mrs. Sumithra R P
Assistant Professor
Department of CSE
UID
User Interface
JS Functions
Design

Lecture 17
Syllabus

Unit II

 CSS Box Model and Positioning - Creating Layouts Using Modern CSS -
Backgrounds and Borders - CSS Transformations and Transitions -
Animating with CSS and the Canvas

 Dynamic Web Pages – Web Scripting – JavaScript programming for Web


Applications – Including JavaScript in HTML – HTML5 Form Controls
and Validation - Document Object Model - DOM manipulation and
events - Event Handlers.

3
JavaScript function
 A JavaScript function is a block of code designed to
perform a particular task.

 A JavaScript function is executed when "something"


invokes it (calls it).
 A JavaScript function is defined with the function
keyword, followed by a name, followed by parentheses
().
function name(parameter1, parameter2, parameter3) {
// code to be executed
}
Function
parameters,Arguments
 Function parameters are listed inside the parentheses ()
in the function definition.

 Function arguments are the values received by the


function when it is invoked.

 Inside the function, the arguments (the parameters)


behave as local variables.
Function Invocation

 The code inside the function will execute when


"something" invokes (calls) the function:
 When an event occurs (when a user clicks a
button)
 When it is invoked (called) from JavaScript code
 Automatically (self invoked)
Function Return

 When JavaScript reaches a return statement,


the function will stop executing.

 If the function was invoked from a statement,


JavaScript will "return" to execute the code
after the invoking statement.

 Functions often compute a return value. The


return value is "returned" back to the "caller":
Local Variables

 Variables declared within a JavaScript function,


become LOCAL to the function.

 Local variables can only be accessed from within


the function.
Exercises
 Write a function named averageOf4Numbers that receives 4
numbers as parameters and returns the mathematical average
between them.
 Write a function named concat3 that receives 3 strings as
parameters (string1, string2, string3) and an additional string
named separator.
 Write a function named mostRepetitions that receives 3
parameters:
 a string - string1
 a string - string2
 a letter
 and returns the string that has the most occurrences of the
specified letter. If both have the same number of
occurrences return string1.

You might also like