JavaScript Strings for Pythonistas (Summary)

Congratulations, you made it to the end of the course! The payments team’s branch-name helper now runs in JavaScript. For PAY-2291, PAY-2304, and PAY-2317, ticket-branch.js prints what ticket_branch.py prints, and the only difference is lowercase true and false.

In this course, you learned how to:

  • Build strings with quotes and insert values with template literals, spanning multiple lines if needed
  • Read one character from the start with brackets or from the end with .at(), and get the string’s length with .length
  • Take a range of characters with .slice(), negative positions included
  • Clean and check text with JavaScript equivalents of Python’s methods, such as .trim(), .toLowerCase(), .startsWith(), .indexOf(), and .includes()
  • Replace every match with .replaceAll()
  • Reproduce the few missing methods inline, such as capitalizing the first letter with title[0].toUpperCase() + title.slice(1)
  • Split at the first separator with .indexOf() and .slice()
  • Split on a separator you name and join the pieces by calling .join() on the array

Keep the Habits That Carry Over

Much of what you know about Python strings still applies. Single and double quotes make the same strings, and escapes such as \n work the same way.

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.