Appending “Hello” to beginning of each item in an array javascript
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have a homework problem asking me to map over the names array, and return a new array with "Hello," appended to the beginning of each name.
The elements are changed when run for the problem.
I have to use an arrow function, and also the map method. I'm having trouble finding how to use both the map method, while making sure it adds "Hello," to each element in the array.
This is the code and what I have so far.
Any suggestions?
var names = "TBD";
var formalGreeting = () => {
names.map("Hello," + names)
};
So far this just adds the hello to the first element.
javascript arrays
add a comment |
I have a homework problem asking me to map over the names array, and return a new array with "Hello," appended to the beginning of each name.
The elements are changed when run for the problem.
I have to use an arrow function, and also the map method. I'm having trouble finding how to use both the map method, while making sure it adds "Hello," to each element in the array.
This is the code and what I have so far.
Any suggestions?
var names = "TBD";
var formalGreeting = () => {
names.map("Hello," + names)
};
So far this just adds the hello to the first element.
javascript arrays
1
You're using the correct function but are not using it right. Refer to the docs. Also, where's your array?
– Jeto
Jan 4 at 18:33
As in the new array? I don't believe it requires me to define one.
– Smith
Jan 4 at 18:37
No, the original one. There's no array at all in your sample.$names
is a string.
– Jeto
Jan 4 at 18:37
Oh i see what you're asking. The "TBD" string is changed when the test runs the code and changes it for an array. I dont have to mess with that.
– Smith
Jan 4 at 18:40
add a comment |
I have a homework problem asking me to map over the names array, and return a new array with "Hello," appended to the beginning of each name.
The elements are changed when run for the problem.
I have to use an arrow function, and also the map method. I'm having trouble finding how to use both the map method, while making sure it adds "Hello," to each element in the array.
This is the code and what I have so far.
Any suggestions?
var names = "TBD";
var formalGreeting = () => {
names.map("Hello," + names)
};
So far this just adds the hello to the first element.
javascript arrays
I have a homework problem asking me to map over the names array, and return a new array with "Hello," appended to the beginning of each name.
The elements are changed when run for the problem.
I have to use an arrow function, and also the map method. I'm having trouble finding how to use both the map method, while making sure it adds "Hello," to each element in the array.
This is the code and what I have so far.
Any suggestions?
var names = "TBD";
var formalGreeting = () => {
names.map("Hello," + names)
};
So far this just adds the hello to the first element.
javascript arrays
javascript arrays
edited Jan 4 at 19:57
ClickThisNick
2,08282550
2,08282550
asked Jan 4 at 18:31
SmithSmith
102
102
1
You're using the correct function but are not using it right. Refer to the docs. Also, where's your array?
– Jeto
Jan 4 at 18:33
As in the new array? I don't believe it requires me to define one.
– Smith
Jan 4 at 18:37
No, the original one. There's no array at all in your sample.$names
is a string.
– Jeto
Jan 4 at 18:37
Oh i see what you're asking. The "TBD" string is changed when the test runs the code and changes it for an array. I dont have to mess with that.
– Smith
Jan 4 at 18:40
add a comment |
1
You're using the correct function but are not using it right. Refer to the docs. Also, where's your array?
– Jeto
Jan 4 at 18:33
As in the new array? I don't believe it requires me to define one.
– Smith
Jan 4 at 18:37
No, the original one. There's no array at all in your sample.$names
is a string.
– Jeto
Jan 4 at 18:37
Oh i see what you're asking. The "TBD" string is changed when the test runs the code and changes it for an array. I dont have to mess with that.
– Smith
Jan 4 at 18:40
1
1
You're using the correct function but are not using it right. Refer to the docs. Also, where's your array?
– Jeto
Jan 4 at 18:33
You're using the correct function but are not using it right. Refer to the docs. Also, where's your array?
– Jeto
Jan 4 at 18:33
As in the new array? I don't believe it requires me to define one.
– Smith
Jan 4 at 18:37
As in the new array? I don't believe it requires me to define one.
– Smith
Jan 4 at 18:37
No, the original one. There's no array at all in your sample.
$names
is a string.– Jeto
Jan 4 at 18:37
No, the original one. There's no array at all in your sample.
$names
is a string.– Jeto
Jan 4 at 18:37
Oh i see what you're asking. The "TBD" string is changed when the test runs the code and changes it for an array. I dont have to mess with that.
– Smith
Jan 4 at 18:40
Oh i see what you're asking. The "TBD" string is changed when the test runs the code and changes it for an array. I dont have to mess with that.
– Smith
Jan 4 at 18:40
add a comment |
3 Answers
3
active
oldest
votes
var names = ['John', 'Max', 'Ellie'];
var namesWithGreeting = (arr) => {
return arr.map(name => "Hello " + name);
}
namesWithGreeting(names);
//Output: ['Hello John', 'Hello Max', 'Hello Ellie']
You pass in an array to your function, and then use the map method to iterate over all the names, returning a new array with all names concatenated with "Hello ".
That totally makes sense. It must have something to do with how the test is run on the function and array which does not let that work. I'm trying to figure out a variation of that to get it to work.
– Smith
Jan 4 at 18:45
var names = "TBD"; var formalGreeting = () => { //Your code here } This is what they provided me fully. I'm thinking they dont want me to put any parameters in for the function because it will do that when it runs the test. Makes testing difficult.
– Smith
Jan 4 at 18:53
That seems strange. What you can do is use thearguments
object in your function.var namesWithGreeting = () => return arguments[0].map(el => "Hello " + el)
– J.L
Jan 5 at 0:51
I think i'm going to have to come back to this one at a later point. I've tried all the variations i can personally think of as well as trying all of the suggested options. I believe many of these are correct, but it has something to do with the input they're using. Super annoying. Thanks though!
– Smith
Jan 5 at 1:56
add a comment |
This will work--
var a=["ashay","neeti"];
var e=(w)=>{return w.map(n=>"Hello "+n)};
alert(e(a));
They have some strange input that causes all of my own variations as well as any of these to not work. I have found they work outside when i determine the input however. Thanks for the response!
– Smith
Jan 5 at 19:22
Finally got it!: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 6 at 1:08
add a comment |
The map()
method calls a provided callback function once for each element in an array, in order, and constructs a new array from the results.
So in the following code snippet, we are mapping the array names
where each element in the array is x
an for each element we return back the element with the string Hello,
appended before it.
As mentioned above, the map()
does not mutate the current array that is being mapped but returns a new array so all we have to do now is assign the new array that you got from mapping names
to the variable newNames
.
var names = ["A", "B", "C"];
var formalGreeting = (array) => {
var newNames = array.map(x => {
return "Hello," + x;
});
console.log(newNames);
};
formalGreeting(names);
This definitely works, but for some reason the inputs they use don't allow it to work. I'm still going to experiment with it. It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run.
– Smith
Jan 5 at 19:23
"It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run." <-- I don't understand.
– AndrewL64
Jan 5 at 19:30
This was the final answer: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 7 at 19:29
Glad you managed to find a fix mate :) Cheers!!
– AndrewL64
Jan 7 at 19:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54044309%2fappending-hello-to-beginning-of-each-item-in-an-array-javascript%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
var names = ['John', 'Max', 'Ellie'];
var namesWithGreeting = (arr) => {
return arr.map(name => "Hello " + name);
}
namesWithGreeting(names);
//Output: ['Hello John', 'Hello Max', 'Hello Ellie']
You pass in an array to your function, and then use the map method to iterate over all the names, returning a new array with all names concatenated with "Hello ".
That totally makes sense. It must have something to do with how the test is run on the function and array which does not let that work. I'm trying to figure out a variation of that to get it to work.
– Smith
Jan 4 at 18:45
var names = "TBD"; var formalGreeting = () => { //Your code here } This is what they provided me fully. I'm thinking they dont want me to put any parameters in for the function because it will do that when it runs the test. Makes testing difficult.
– Smith
Jan 4 at 18:53
That seems strange. What you can do is use thearguments
object in your function.var namesWithGreeting = () => return arguments[0].map(el => "Hello " + el)
– J.L
Jan 5 at 0:51
I think i'm going to have to come back to this one at a later point. I've tried all the variations i can personally think of as well as trying all of the suggested options. I believe many of these are correct, but it has something to do with the input they're using. Super annoying. Thanks though!
– Smith
Jan 5 at 1:56
add a comment |
var names = ['John', 'Max', 'Ellie'];
var namesWithGreeting = (arr) => {
return arr.map(name => "Hello " + name);
}
namesWithGreeting(names);
//Output: ['Hello John', 'Hello Max', 'Hello Ellie']
You pass in an array to your function, and then use the map method to iterate over all the names, returning a new array with all names concatenated with "Hello ".
That totally makes sense. It must have something to do with how the test is run on the function and array which does not let that work. I'm trying to figure out a variation of that to get it to work.
– Smith
Jan 4 at 18:45
var names = "TBD"; var formalGreeting = () => { //Your code here } This is what they provided me fully. I'm thinking they dont want me to put any parameters in for the function because it will do that when it runs the test. Makes testing difficult.
– Smith
Jan 4 at 18:53
That seems strange. What you can do is use thearguments
object in your function.var namesWithGreeting = () => return arguments[0].map(el => "Hello " + el)
– J.L
Jan 5 at 0:51
I think i'm going to have to come back to this one at a later point. I've tried all the variations i can personally think of as well as trying all of the suggested options. I believe many of these are correct, but it has something to do with the input they're using. Super annoying. Thanks though!
– Smith
Jan 5 at 1:56
add a comment |
var names = ['John', 'Max', 'Ellie'];
var namesWithGreeting = (arr) => {
return arr.map(name => "Hello " + name);
}
namesWithGreeting(names);
//Output: ['Hello John', 'Hello Max', 'Hello Ellie']
You pass in an array to your function, and then use the map method to iterate over all the names, returning a new array with all names concatenated with "Hello ".
var names = ['John', 'Max', 'Ellie'];
var namesWithGreeting = (arr) => {
return arr.map(name => "Hello " + name);
}
namesWithGreeting(names);
//Output: ['Hello John', 'Hello Max', 'Hello Ellie']
You pass in an array to your function, and then use the map method to iterate over all the names, returning a new array with all names concatenated with "Hello ".
answered Jan 4 at 18:38
J.LJ.L
363
363
That totally makes sense. It must have something to do with how the test is run on the function and array which does not let that work. I'm trying to figure out a variation of that to get it to work.
– Smith
Jan 4 at 18:45
var names = "TBD"; var formalGreeting = () => { //Your code here } This is what they provided me fully. I'm thinking they dont want me to put any parameters in for the function because it will do that when it runs the test. Makes testing difficult.
– Smith
Jan 4 at 18:53
That seems strange. What you can do is use thearguments
object in your function.var namesWithGreeting = () => return arguments[0].map(el => "Hello " + el)
– J.L
Jan 5 at 0:51
I think i'm going to have to come back to this one at a later point. I've tried all the variations i can personally think of as well as trying all of the suggested options. I believe many of these are correct, but it has something to do with the input they're using. Super annoying. Thanks though!
– Smith
Jan 5 at 1:56
add a comment |
That totally makes sense. It must have something to do with how the test is run on the function and array which does not let that work. I'm trying to figure out a variation of that to get it to work.
– Smith
Jan 4 at 18:45
var names = "TBD"; var formalGreeting = () => { //Your code here } This is what they provided me fully. I'm thinking they dont want me to put any parameters in for the function because it will do that when it runs the test. Makes testing difficult.
– Smith
Jan 4 at 18:53
That seems strange. What you can do is use thearguments
object in your function.var namesWithGreeting = () => return arguments[0].map(el => "Hello " + el)
– J.L
Jan 5 at 0:51
I think i'm going to have to come back to this one at a later point. I've tried all the variations i can personally think of as well as trying all of the suggested options. I believe many of these are correct, but it has something to do with the input they're using. Super annoying. Thanks though!
– Smith
Jan 5 at 1:56
That totally makes sense. It must have something to do with how the test is run on the function and array which does not let that work. I'm trying to figure out a variation of that to get it to work.
– Smith
Jan 4 at 18:45
That totally makes sense. It must have something to do with how the test is run on the function and array which does not let that work. I'm trying to figure out a variation of that to get it to work.
– Smith
Jan 4 at 18:45
var names = "TBD"; var formalGreeting = () => { //Your code here } This is what they provided me fully. I'm thinking they dont want me to put any parameters in for the function because it will do that when it runs the test. Makes testing difficult.
– Smith
Jan 4 at 18:53
var names = "TBD"; var formalGreeting = () => { //Your code here } This is what they provided me fully. I'm thinking they dont want me to put any parameters in for the function because it will do that when it runs the test. Makes testing difficult.
– Smith
Jan 4 at 18:53
That seems strange. What you can do is use the
arguments
object in your function. var namesWithGreeting = () => return arguments[0].map(el => "Hello " + el)
– J.L
Jan 5 at 0:51
That seems strange. What you can do is use the
arguments
object in your function. var namesWithGreeting = () => return arguments[0].map(el => "Hello " + el)
– J.L
Jan 5 at 0:51
I think i'm going to have to come back to this one at a later point. I've tried all the variations i can personally think of as well as trying all of the suggested options. I believe many of these are correct, but it has something to do with the input they're using. Super annoying. Thanks though!
– Smith
Jan 5 at 1:56
I think i'm going to have to come back to this one at a later point. I've tried all the variations i can personally think of as well as trying all of the suggested options. I believe many of these are correct, but it has something to do with the input they're using. Super annoying. Thanks though!
– Smith
Jan 5 at 1:56
add a comment |
This will work--
var a=["ashay","neeti"];
var e=(w)=>{return w.map(n=>"Hello "+n)};
alert(e(a));
They have some strange input that causes all of my own variations as well as any of these to not work. I have found they work outside when i determine the input however. Thanks for the response!
– Smith
Jan 5 at 19:22
Finally got it!: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 6 at 1:08
add a comment |
This will work--
var a=["ashay","neeti"];
var e=(w)=>{return w.map(n=>"Hello "+n)};
alert(e(a));
They have some strange input that causes all of my own variations as well as any of these to not work. I have found they work outside when i determine the input however. Thanks for the response!
– Smith
Jan 5 at 19:22
Finally got it!: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 6 at 1:08
add a comment |
This will work--
var a=["ashay","neeti"];
var e=(w)=>{return w.map(n=>"Hello "+n)};
alert(e(a));
This will work--
var a=["ashay","neeti"];
var e=(w)=>{return w.map(n=>"Hello "+n)};
alert(e(a));
answered Jan 4 at 18:42
ellipsisellipsis
8,3032929
8,3032929
They have some strange input that causes all of my own variations as well as any of these to not work. I have found they work outside when i determine the input however. Thanks for the response!
– Smith
Jan 5 at 19:22
Finally got it!: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 6 at 1:08
add a comment |
They have some strange input that causes all of my own variations as well as any of these to not work. I have found they work outside when i determine the input however. Thanks for the response!
– Smith
Jan 5 at 19:22
Finally got it!: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 6 at 1:08
They have some strange input that causes all of my own variations as well as any of these to not work. I have found they work outside when i determine the input however. Thanks for the response!
– Smith
Jan 5 at 19:22
They have some strange input that causes all of my own variations as well as any of these to not work. I have found they work outside when i determine the input however. Thanks for the response!
– Smith
Jan 5 at 19:22
Finally got it!: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 6 at 1:08
Finally got it!: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 6 at 1:08
add a comment |
The map()
method calls a provided callback function once for each element in an array, in order, and constructs a new array from the results.
So in the following code snippet, we are mapping the array names
where each element in the array is x
an for each element we return back the element with the string Hello,
appended before it.
As mentioned above, the map()
does not mutate the current array that is being mapped but returns a new array so all we have to do now is assign the new array that you got from mapping names
to the variable newNames
.
var names = ["A", "B", "C"];
var formalGreeting = (array) => {
var newNames = array.map(x => {
return "Hello," + x;
});
console.log(newNames);
};
formalGreeting(names);
This definitely works, but for some reason the inputs they use don't allow it to work. I'm still going to experiment with it. It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run.
– Smith
Jan 5 at 19:23
"It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run." <-- I don't understand.
– AndrewL64
Jan 5 at 19:30
This was the final answer: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 7 at 19:29
Glad you managed to find a fix mate :) Cheers!!
– AndrewL64
Jan 7 at 19:31
add a comment |
The map()
method calls a provided callback function once for each element in an array, in order, and constructs a new array from the results.
So in the following code snippet, we are mapping the array names
where each element in the array is x
an for each element we return back the element with the string Hello,
appended before it.
As mentioned above, the map()
does not mutate the current array that is being mapped but returns a new array so all we have to do now is assign the new array that you got from mapping names
to the variable newNames
.
var names = ["A", "B", "C"];
var formalGreeting = (array) => {
var newNames = array.map(x => {
return "Hello," + x;
});
console.log(newNames);
};
formalGreeting(names);
This definitely works, but for some reason the inputs they use don't allow it to work. I'm still going to experiment with it. It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run.
– Smith
Jan 5 at 19:23
"It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run." <-- I don't understand.
– AndrewL64
Jan 5 at 19:30
This was the final answer: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 7 at 19:29
Glad you managed to find a fix mate :) Cheers!!
– AndrewL64
Jan 7 at 19:31
add a comment |
The map()
method calls a provided callback function once for each element in an array, in order, and constructs a new array from the results.
So in the following code snippet, we are mapping the array names
where each element in the array is x
an for each element we return back the element with the string Hello,
appended before it.
As mentioned above, the map()
does not mutate the current array that is being mapped but returns a new array so all we have to do now is assign the new array that you got from mapping names
to the variable newNames
.
var names = ["A", "B", "C"];
var formalGreeting = (array) => {
var newNames = array.map(x => {
return "Hello," + x;
});
console.log(newNames);
};
formalGreeting(names);
The map()
method calls a provided callback function once for each element in an array, in order, and constructs a new array from the results.
So in the following code snippet, we are mapping the array names
where each element in the array is x
an for each element we return back the element with the string Hello,
appended before it.
As mentioned above, the map()
does not mutate the current array that is being mapped but returns a new array so all we have to do now is assign the new array that you got from mapping names
to the variable newNames
.
var names = ["A", "B", "C"];
var formalGreeting = (array) => {
var newNames = array.map(x => {
return "Hello," + x;
});
console.log(newNames);
};
formalGreeting(names);
var names = ["A", "B", "C"];
var formalGreeting = (array) => {
var newNames = array.map(x => {
return "Hello," + x;
});
console.log(newNames);
};
formalGreeting(names);
var names = ["A", "B", "C"];
var formalGreeting = (array) => {
var newNames = array.map(x => {
return "Hello," + x;
});
console.log(newNames);
};
formalGreeting(names);
edited Jan 4 at 18:49
answered Jan 4 at 18:44
AndrewL64AndrewL64
10.3k42047
10.3k42047
This definitely works, but for some reason the inputs they use don't allow it to work. I'm still going to experiment with it. It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run.
– Smith
Jan 5 at 19:23
"It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run." <-- I don't understand.
– AndrewL64
Jan 5 at 19:30
This was the final answer: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 7 at 19:29
Glad you managed to find a fix mate :) Cheers!!
– AndrewL64
Jan 7 at 19:31
add a comment |
This definitely works, but for some reason the inputs they use don't allow it to work. I'm still going to experiment with it. It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run.
– Smith
Jan 5 at 19:23
"It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run." <-- I don't understand.
– AndrewL64
Jan 5 at 19:30
This was the final answer: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 7 at 19:29
Glad you managed to find a fix mate :) Cheers!!
– AndrewL64
Jan 7 at 19:31
This definitely works, but for some reason the inputs they use don't allow it to work. I'm still going to experiment with it. It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run.
– Smith
Jan 5 at 19:23
This definitely works, but for some reason the inputs they use don't allow it to work. I'm still going to experiment with it. It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run.
– Smith
Jan 5 at 19:23
"It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run." <-- I don't understand.
– AndrewL64
Jan 5 at 19:30
"It's basically asking to have empty inputs everywhere and they fill out all of the inputs when the "test" is run." <-- I don't understand.
– AndrewL64
Jan 5 at 19:30
This was the final answer: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 7 at 19:29
This was the final answer: var formalGreeting = () => { return names.map((names) => "Hello, "+names) }
– Smith
Jan 7 at 19:29
Glad you managed to find a fix mate :) Cheers!!
– AndrewL64
Jan 7 at 19:31
Glad you managed to find a fix mate :) Cheers!!
– AndrewL64
Jan 7 at 19:31
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54044309%2fappending-hello-to-beginning-of-each-item-in-an-array-javascript%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You're using the correct function but are not using it right. Refer to the docs. Also, where's your array?
– Jeto
Jan 4 at 18:33
As in the new array? I don't believe it requires me to define one.
– Smith
Jan 4 at 18:37
No, the original one. There's no array at all in your sample.
$names
is a string.– Jeto
Jan 4 at 18:37
Oh i see what you're asking. The "TBD" string is changed when the test runs the code and changes it for an array. I dont have to mess with that.
– Smith
Jan 4 at 18:40