Back to Freecodecamp

Step 13

curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/6552008c0d9d9075cbec9772.md

latest1.3 KB
Original Source

--description--

You are going to use the .find() method to find the position in the alphabet of each letter in your message. A method is similar to a function, but it belongs to an object.

py
sentence = 'My brain hurts!'
sentence.find('r')

Above, the .find() method is called on sentence (the string to search in), and 'r' (the character to locate) is passed as the argument. The sentence.find('r') call will return 4, which is the index of the first occurrence of 'r' in sentence.

At the end of your code, call .find() on alphabet and pass 'z' as the argument to the method.

--hints--

You should call the .find() method.

js
assert.match(code, /find\s*\(.*\)/)

You should call the .find() method on the alphabet variable.

js
assert.match(code, /alphabet\.find\s*\(.*\)/)

You should call the .find() method on the alphabet variable and pass 'z' to the method. Pay attention to place the method call at the beginning of the line.

js
assert.match(code, /^alphabet\.find\s*\(\s*('|")z\1\s*\)/m)

Your code contains invalid syntax and/or invalid indentation.

js
({test: () => assert(true) })

--seed--

--seed-contents--

py
--fcc-editable-region--
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
--fcc-editable-region--