Beginner's Guide to Coding and Data

Level: Beginner

Using code to interrogate textual data | I'm a STRING. Ask me anything! | Coding tutorial

video

expand_more chevron_left

text

expand_more chevron_left

Introducing String Manipulation with JavaScript and PowerShell

Hey, everyone! We're diving into an exciting topic in this lessonβ€”how to build and interrogate strings using JavaScript and PowerShell. Let's jump straight into it, shall we?

To follow along, we recommend having both a PowerShell and a JavaScript environment ready for experimentation.

Introduction to Strings

Strings are sequences of characters that represent textual data within computer programs. We've previously looked at how strings serve various purposes like defining log messages or IDs for web elements. Today, our focus is on interacting with strings programmatically.

  • Building Strings
  • Interrogating Strings

Logging and String References

We can easily display messages in both environmentsβ€”using Write-Host in PowerShell and console.log in JavaScript. Let's also see how we can create string references in both languages.

// In JavaScript
let name = "DEEPLIZARD";
// In PowerShell
$name = "DEEPLIZARD";

We just created a reference called name that can be used to refer to the string DEEPLIZARD in both languages.

In PowerShell, references to strings are required to start with a $ symbol. In JavaScript, this is not required. However, it is a common practice to use the let keyword to declare a reference to a string. This shows us how the same concept can be implemented in different ways in different languages.

Building Strings

What if we start with two separate strings, deep and lizard, and want to combine them? We can easily accomplish this through string concatenation.

// JavaScript
let fullString = "deep" + "lizard";

This gives us a new reference, fullString, that combines both strings into a single one: deeplizard.

Interrogating Strings

Once we have a string or a reference to a string, we can interrogate it to obtain various kinds of information. Here are some questions we might ask:

  • What type of data are you?
  • What character is present at index 6?
  • What is the index of the letter 'Z'?
  • Do you end with the word 'lizard'?
  • Do you start with the word 'lizard'?

Each programming language has its own methods for these operations. For example, PowerShell uses contains while JavaScript uses includes to check if a string contains a particular substring.

// In JavaScript
let name = "deeplizard";
name.includes("lizard"); // True
// In PowerShell
$name = "deeplizard";
$name -contains "lizard"; # True

Both commands accomplish the same task but in their respective idiomatic ways.

If you're interested in diving deeper, you can always Google string methods along with the programming language of your choice. Got any questions? Feel free to drop them in the comments.

quiz

expand_more chevron_left
deeplizard logo DEEPLIZARD Message notifications

Quiz Results

resources

expand_more chevron_left
What's going on everyone. In this video πŸŽ₯, we will use JavaScript and PowerShell to see how we can build and interrogate strings using code πŸ’». Textual data inside computer programs is represented using sequences of characters that we call strings. So far in this series, we seen how strings can be used to do things like, define a log message or define an id for an element on a web page. Now, we will see how we can interact with strings using code. With code, there are two powerful things we can do. 1) We can use code to build strings. 2) We can use code to interrogate strings. To do this, we will work in PowerShell and JavaScript side by side. Let's get to it. Notebook for this one: https://beta.observablehq.com/@deeplizard/using-code-to-interrogate-textual-data String methods: PowerShell - https://msdn.microsoft.com/en-us/library/system.string_methods(v=vs.110).aspx JavaScript - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#Methods πŸ•’πŸ¦Ž VIDEO SECTIONS πŸ¦ŽπŸ•’ 00:00 Welcome to DEEPLIZARD - Go to deeplizard.com for learning resources 00:30 Help deeplizard add video timestamps - See example in the description 05:53 Collective Intelligence and the DEEPLIZARD HIVEMIND πŸ’₯🦎 DEEPLIZARD COMMUNITY RESOURCES 🦎πŸ’₯ πŸ‘‹ Hey, we're Chris and Mandy, the creators of deeplizard! πŸ‘€ CHECK OUT OUR VLOG: πŸ”— https://youtube.com/deeplizardvlog πŸ’ͺ CHECK OUT OUR FITNESS CHANNEL: πŸ”— https://www.youtube.com/channel/UCdCxHNCexDrAx78VfAuyKiA 🧠 Use code DEEPLIZARD at checkout to receive 15% off your first Neurohacker order: πŸ”— https://neurohacker.com/shop?rfsn=6488344.d171c6 ❀️🦎 Special thanks to the following polymaths of the deeplizard hivemind: Mano Prime πŸ‘€ Follow deeplizard: Our vlog: https://youtube.com/deeplizardvlog Fitness: https://www.youtube.com/channel/UCdCxHNCexDrAx78VfAuyKiA Facebook: https://facebook.com/deeplizard Instagram: https://instagram.com/deeplizard Twitter: https://twitter.com/deeplizard Patreon: https://patreon.com/deeplizard YouTube: https://youtube.com/deeplizard πŸŽ“ Deep Learning with deeplizard: AI Art for Beginners - https://deeplizard.com/course/sdcpailzrd Deep Learning Dictionary - https://deeplizard.com/course/ddcpailzrd Deep Learning Fundamentals - https://deeplizard.com/course/dlcpailzrd Learn TensorFlow - https://deeplizard.com/course/tfcpailzrd Learn PyTorch - https://deeplizard.com/course/ptcpailzrd Natural Language Processing - https://deeplizard.com/course/txtcpailzrd Reinforcement Learning - https://deeplizard.com/course/rlcpailzrd Generative Adversarial Networks - https://deeplizard.com/course/gacpailzrd Stable Diffusion Masterclass - https://deeplizard.com/course/dicpailzrd πŸŽ“ Other Courses: DL Fundamentals Classic - https://deeplizard.com/learn/video/gZmobeGL0Yg Deep Learning Deployment - https://deeplizard.com/learn/video/SI1hVGvbbZ4 Data Science - https://deeplizard.com/learn/video/d11chG7Z-xk Trading - https://deeplizard.com/learn/video/ZpfCK_uHL9Y πŸ›’ Check out products deeplizard recommends on Amazon: πŸ”— https://amazon.com/shop/deeplizard πŸ“• Get a FREE 30-day Audible trial and 2 FREE audio books using deeplizard's link: πŸ”— https://amzn.to/2yoqWRn 🎡 deeplizard uses music by Kevin MacLeod πŸ”— https://youtube.com/channel/UCSZXFhRIx6b0dFX3xS8L1yQ ❀️ Please use the knowledge gained from deeplizard content for good, not evil.

updates

expand_more chevron_left
deeplizard logo DEEPLIZARD Message notifications

Update history for this page

Did you know you that deeplizard content is regularly updated and maintained?

  • Updated
  • Maintained

Spot something that needs to be updated? Don't hesitate to let us know. We'll fix it!


All relevant updates for the content on this page are listed below.