Files

28 lines
656 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Understand String Immutability
---
# Understand String Immutability
2018-10-12 15:37:13 -04:00
---
## Hints
### Hint 1
2019-01-15 14:52:33 -08:00
Instead of ```Jello World ```, ```myStr``` should be assigned ```Hello World```.
2018-10-12 15:37:13 -04:00
---
## Solutions
<details><summary>Solution 1 (Click to Show/Hide)</summary>
2019-01-15 14:52:33 -08:00
```javascript
// Setup
var myStr = "Jello World";
// Only change code below this line
myStr = "Hello World";
2019-01-15 14:52:33 -08:00
```
#### Code Explanation
2019-01-15 14:52:33 -08:00
String literals such as ```"Jello World"``` cannot be changed by the individual letter (hence being *immutable*), so the variable containing the incorrect string must be replaced with the desired string using the assignment operator ```=```
</details>