2018-09-30 23:01:58 +01:00
---
id: bd7123c9c444eddfaeb5bdef
title: Declare String Variables
challengeType: 1
2019-02-14 12:24:02 -05:00
videoUrl: 'https://scrimba.com/c/c2QvWU6'
2019-07-31 11:32:23 -07:00
forumTopicId: 17557
2018-09-30 23:01:58 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
Previously we have used the code
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
`var myName = "your name";`
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
`"your name"` is called a < dfn > string</ dfn > < dfn > literal</ dfn > . It is a string because it is a series of zero or more characters enclosed in single or double quotes.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --instructions--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
Create two new `string` variables: `myFirstName` and `myLastName` and assign them the values of your first and last name, respectively.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --hints--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
`myFirstName` should be a string with at least one character in it.
2018-09-30 23:01:58 +01:00
```js
2020-11-27 19:02:05 +01:00
assert(
(function () {
if (
typeof myFirstName !== 'undefined' & &
typeof myFirstName === 'string' & &
myFirstName.length > 0
) {
return true;
} else {
return false;
}
})()
);
```
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
`myLastName` should be a string with at least one character in it.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(
(function () {
if (
typeof myLastName !== 'undefined' & &
typeof myLastName === 'string' & &
myLastName.length > 0
) {
return true;
} else {
return false;
}
})()
);
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
# --seed--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
## --after-user-code--
2018-09-30 23:01:58 +01:00
```js
2018-10-20 21:02:47 +03:00
if(typeof myFirstName !== "undefined" & & typeof myLastName !== "undefined"){(function(){return myFirstName + ', ' + myLastName;})();}
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
## --seed-contents--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
```
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --solutions--
2018-09-30 23:01:58 +01:00
```js
var myFirstName = "Alan";
var myLastName = "Turing";
```