Table of contents
Learn Dynamic JS Functions in a fun way
So let's write it straight away. As the name suggests, dynamic functions are not something hard-coded or static.
Live Example:
Try: Navigate to the JS Section and replace your "name" & "country" in place of "Shizuoka" & "Japan"
Let's Write
Let's write our function and call it getInput() since we are getting input from the user
function getInput(city) {}
Let's write our code inside the function.
function getInput(city) {
console.log("I am from" + city )
}
I am logging out the city input mentioned by our user by adding it to "I am from" string
Let's call the function. Here's the complete code
function getInput(city) {
console.log("I am from " + city )
}
getInput("London")
The output will be as
I am from London
You will be using dynamic functions a lot as your program gets complex in real-world projects and advanced javascript programs
Let's learn more about Attributes and methods in the coming lessons