Writing the Methods JavaScript Doesn't Have

With .replaceAll(), the port of ticket_branch.py builds Python’s slug. The line that tidies the title, title.strip().rstrip("."), drops PAY-2304’s full stop, which both the review bot and git reject. JavaScript’s string toolkit is smaller than Python’s, and this line is where it shows.

Strip the Full Stop From PAY-2304

With strip() as .trim() and rstrip() as .trimEnd(), the port follows the Python code line by line:

Language: JavaScript
const key = "PAY-2304";
const rawTitle = " Retry failed card payments.";
const title = rawTitle.trim().trimEnd(".");
console.log(`Commit: ${key}: ${title}`);

Python prints the subject without the full stop. Predict the port’s line, then run it:

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.