Hello I need help with this coding problem I have to do is Sentences:
"the quick brown fox "
"jumps over the lazy dog "
NOTE 1: Spaces have been provided for you so you simply have to use
the +
operator to join together the correct strings.
And the whole code is /* DO NOT DELETE*/
var arr = ["fox ", "dog ", "the ", "over "];
var obj = {
fast: "quick ",
slow: "lazy ",
color: "brown ",
verb: "jumps ",
};
var sentence1;
var sentence2;
/* DO NOT DELETE */
function yourAnswerHere() {
// YOUR CODE BELOW HERE
Sentence1
Sentence 2
i don’t know if i am right or not but
// Sentence 1: "the quick brown fox "
sentence1 = arr[2] + obj.fast + obj.color + arr[0];
// Sentence 2: "jumps over the lazy dog "
sentence2 = obj.verb + arr[3] + arr[2] + obj.slow + arr[1];
here i think this supposed to be like this
This is a JavaScript question, rather than Postman specific.
You have an array and an object, and neither are in any particular order in relation to the two sentences.
You sort of indicated that you want a function, but I can’t really see what advantage a function would have here. Is this part of a training course? Understanding why would enable us to provide a better response.
To target elements within an array, you need the array index number. To target the elements within an JavaScript object, you can use dotted or bracket notation which @docking-module-expl5 has provided an example of mixing the two. (Array indexes start at zero).
What have you come up with so far?
Anyway, here is another option using string literals (backticks) to build up the sentence.
/* DO NOT DELETE*/
var arr = ["fox ", "dog ", "the ", "over "];
var obj = {
fast: "quick ",
slow: "lazy ",
color: "brown ",
verb: "jumps ",
};
var sentence1;
var sentence2;
/* DO NOT DELETE */
console.log(`${arr[2]}${obj.fast}${obj.color}${arr[0]}`) / "the quick brown fox "
console.log(`${obj.verb}${arr[3]}${arr[2]}${obj.slow}${arr[1]}`) / "jumps over the lazy dog "