Clarification needed

activities

#1

Hi Team,

Question:
“How can we test if a given address (a string variable called fullAddress) can be found on a particular street (a string variable called streetName)?”

For the above question I opted for streetName.contains(fulladdress) as we are searching the fulladdress in streetname variable. Is my understanding correct? I chose the same but its wrong. Can any one explain whether my interpretation is wrong?


#2

Hi Gopinath,

I think you misunderstood the question, question is like Street Address contains in Full Address, therefore answer will be fulladdress.contains(streetName).


#3

A street name will always be in a full address and not the other way round. Consider this example:

Full address: 222 B Baker’s Street. Now this address (which means the place this address refers to) will be found in Baker’s street, right? AND the full address contains the street name, “Baker’s Street”. Apply the same logic in your question, too. :wink: