Advertisement
Hydron

Untitled

Apr 14th, 2022
783
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function isCharPresent(str, chr){
  2.     for (let i = 0; i < str.length; i += 1){
  3.         if (str[i] == chr){
  4.             return true;
  5.         }
  6.     }
  7.     return false;
  8. }
  9.  
  10. function charIndexOf(str, chr){
  11.     for (let i = 0; i < str.length; i += 1){
  12.         if (str[i] == chr){
  13.             return i;
  14.         }
  15.     }
  16.     return -1;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement