Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function findIndex(symbol,text)
- {
- var bonusAr=[]
- var bl=true;
- for(i =0;i<symbol.length;i++)
- {
- var arr=[]
- for(a=0;a<text.length;a++)
- {
- if(text[a]===symbol[i])
- {
- arr.push(a)
- bl=false;
- }
- }
- if(arr.length===0)
- {
- bonusAr.push('doesnot exist '+symbol[i])
- }
- else if(arr.length>0)
- {
- bonusAr.push(arr )
- }
- }
- if(bl)
- {
- return 'this symbol doesnot exist in first argument'
- }
- if(bonusAr.length===1)
- {
- if(bonusAr[0].length===1)
- return bonusAr[0][0]
- }
- return bonusAr;
- }
- console.log(findIndex('a','hi it is for homework'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement