SHARE
TWEET

Untitled

a guest Jul 17th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function findIndex(symbol,text)
  2. {
  3.    
  4.     var bonusAr=[]
  5.     var bl=true;
  6.     for(i =0;i<symbol.length;i++)
  7.     {
  8.         var arr=[]
  9.         for(a=0;a<text.length;a++)
  10.         {
  11.          if(text[a]===symbol[i])
  12.         {
  13.            arr.push(a)
  14.            bl=false;
  15.         }
  16.         }
  17.         if(arr.length===0)
  18.         {
  19.             bonusAr.push('doesnot exist '+symbol[i])
  20.         }
  21.         else if(arr.length>0)
  22.         {
  23.         bonusAr.push(arr )
  24.         }
  25.     }
  26.     if(bl)
  27.         {
  28.             return 'this symbol doesnot exist in first argument'
  29.         }
  30.         if(bonusAr.length===1)
  31.             {
  32.                 if(bonusAr[0].length===1)
  33.             return bonusAr[0][0]
  34.             }
  35.            
  36.         return bonusAr;
  37.  
  38. }
  39.  
  40.  
  41. console.log(findIndex('a','hi it is for homework'))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top