Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

make a function and return the index of specific character in javascript

/* making a function that returns the index of the specific character in 
Javascript */
function myFunction(x, y) {
  let myString = x;
  let myIndex = y;
  return myString.charAt(myIndex);
}
console.log(myFunction("Hey Coders, I am Rehman", 5)); // Output would be "o"
console.log(myFunction("Hey Coders, I am Coder", 0)); // Output would be "H"

Source by riptutorial.com #
 
PREVIOUS NEXT
Tagged: #function #return #index #specific #character #javascript
ADD COMMENT
Topic
Name
7+7 =