nearBy AZ


#1


Anyone can help me with this problem? It should work, but id does not


// Write a method that takes a string in and returns true if the letter
//# "z" appears within three letters **after** an "a". You may assume
//# that the string contains only lowercase letters.
function nearBy_az(string) {
    var indA
    var indZ
    len = string.length
    for(i=0; i<=len; i++){ 
        indA == i
    }
    for(j=i+1; j<=len; j++) {
        indZ == j
    }
    if(string [indA] =="a" && string[indZ] == "z" && indA+indZ<=3) {
        return true
    }
    
    return false

}
        
 

nearBy_az("bacz")


#2

Link to the lesson please.


#3

Yeah please sent me a screenshot I will love to help with your code.


#4

Hi, it is not from a codeacademy. I thought it is possible to do it with for loop. Problem description you can see on the top of the code.
Thank you


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.