Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

81 lines
1.4 KiB
Markdown

---
id: bd7123c9c444eddfaeb5bdef
title: Declare String Variables
challengeType: 1
forumTopicId: 17557
dashedName: declare-string-variables
---
# --description--
Previously you used the following code to declare a variable:
```js
var myName;
```
But you can also declare a string variable like this:
```js
var myName = "your name";
```
`"your name"` is called a <dfn>string</dfn> <dfn>literal</dfn>. A string literal, or string, is a series of zero or more characters enclosed in single or double quotes.
# --instructions--
Create two new string variables: `myFirstName` and `myLastName` and assign them the values of your first and last name, respectively.
# --hints--
`myFirstName` should be a string with at least one character in it.
```js
assert(
(function () {
if (
typeof myFirstName !== 'undefined' &&
typeof myFirstName === 'string' &&
myFirstName.length > 0
) {
return true;
} else {
return false;
}
})()
);
```
`myLastName` should be a string with at least one character in it.
```js
assert(
(function () {
if (
typeof myLastName !== 'undefined' &&
typeof myLastName === 'string' &&
myLastName.length > 0
) {
return true;
} else {
return false;
}
})()
);
```
# --seed--
## --seed-contents--
```js
```
# --solutions--
```js
var myFirstName = "Alan";
var myLastName = "Turing";
```