You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility
When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!
If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer!
Hi, I am working on the CODE CHALLENGES: INTERMEDIATE JAVASCRIPT shoutGreetings() one, link:https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-javascript-syntax-part-ii/modules/fecp-practice-javascript-syntax-arrays-loops-objects-iterators/lessons/intermediate-javascript-coding-challenge/exercises/shout-greetings.
I write two ways to solve the problem using map and forEach, But none is working. Could someone explain my problem why i am getting undefined?
// Write your code here:
const shoutGreetings = arr => arr.map(word => word.toUpperCase() + '!');
const shoutGreetings1 = function(arr) {
arr.map (function(element){
return element.toUpperCase() + '!'
});
}
const shoutGreetings2 = function(arr) {
const newarr = [];
arr.forEach(function(element){
newarr.push(element.toUpperCase() + '!')
});
}
// Feel free to uncomment out the code below to test your function!
const greetings = ['hello', 'hi', 'heya', 'oi', 'hey', 'yo'];
console.log(shoutGreetings(greetings));
console.log(shoutGreetings1(greetings)); //undefined
console.log(shoutGreetings2(greetings)); //undefined
// Should print [ 'HELLO!', 'HI!', 'HEYA!', 'OI!', 'HEY!', 'YO!' ]