[ ] 3: Commit your updated function code in twocatz/index.js to the twocatz branch, create a pull request, and only merge the PR when the bot approves your changes!
🚧 Test your Work
When you paste your Function URL in your browser or make a GET request with Postman, you might get something like:
Generate a random number within the range of the array length
❓ How do I generate two random names?
1. Create an array with the names:
```js
let names = ["name1", "name2"...]
```
2. Generate a random value in the correct range:
```js
let random_value = Math.floor(names.length * Math.random())
```
3. Get the name!
```js
let resultname = names[random_value]
```
4. Wrap the code for generating a random combination into a function that returns resultname and call the function twice to get two names!
2: Return images in JSON format
context.res is the key to answering this question!
❓ How do I return the images using context.res?
To return your two images and two names in the output:
```js
context.res = {
body: {
cat1: your-first-catpicture-in-base64,
cat2: your-second-catpicture-in-base64,
names: [name1, name2]
}
}
```
Week 1 Step 7 ⬤⬤⬤⬤⬤⬤⬤◯◯ | 🕐 Estimated completion: 5-15 minutes
Name your Cat
✅ Task:
git pull
twocatz/index.js
to thetwocatz
branch, create a pull request, and only merge the PR when the bot approves your changes!🚧 Test your Work
When you paste your Function URL in your browser or make a GET request with Postman, you might get something like:
1: Select random items out of a list
❓ How do I generate two random names?
1. Create an array with the names: ```js let names = ["name1", "name2"...] ``` 2. Generate a random value in the correct range: ```js let random_value = Math.floor(names.length * Math.random()) ``` 3. Get the name! ```js let resultname = names[random_value] ``` 4. Wrap the code for generating a random combination into a function that returns resultname and call the function twice to get two names!2: Return images in JSON format
context.res
is the key to answering this question!❓ How do I return the images using context.res?
To return your two images and two names in the output: ```js context.res = { body: { cat1: your-first-catpicture-in-base64, cat2: your-second-catpicture-in-base64, names: [name1, name2] } } ```