homework.md
Is there anyone who can help me with homework ( Working with movies)
I just dont know where and how to start
what do you have so far?
where are you stuck?
what specifically do you need help with?
We can often help, we’re a pretty helpful bunch (if you can ignore my straitjacket) - but we aren’t doing your homework for you.
If you like, post what you’ve done so far in some online sandbox (like repl, or codepen, or jsfiddle, and then post the link to what you’ve tried here. Let us know if there’s something going on that you don’t expect, or if you don’t know quite how to get the result you want.
But you have to put in some legwork first.
For a start, you must use map, filter and reduce. Freecodecamp has a useful series about JavaScript basics, in addition you can take a look at them on Mozilla MDN.
Did you check the Week 5 preparation links?
Can you show us how you would try to solve the first challenge?
- Create an array of movies containing the movies with a short title (you define what short means)
Thank you very much your replay i dont mean that someone has to do my homework but just if i get some guidance
i have done the first like this:
let numbers = [1, 2, 3, 4];
// let newNumbers = [];
// for(let i = 0; i < numbers.length; i++) {
// if(numbers[i] % 2 !== 0) {
// newNumbers[i] = numbers[i] * 2;
// }
// }
// console.log(“The doubled numbers are”, newNumbers); // [2, 6]
const doublingNumbers = numbers
.filter(number => number % 2 !== 0)
.map(number => number * 2)
console.log(doublingNumbers);
for the second instruction i copied the array of the movie but i could not do instruction number 2
let numbers = [1, 2, 3, 4];
// let newNumbers = [];
// for(let i = 0; i < numbers.length; i++) {
// if(numbers[i] % 2 !== 0) {
// newNumbers[i] = numbers[i] * 2;
// }
// }
// console.log(“The doubled numbers are”, newNumbers); // [2, 6]
const doublingNumbers = numbers
.filter(number => number % 2 !== 0)
.map(number => number * 2)
console.log(doublingNumbers);
here is what i have done so far
and for the second homework i copied array of the movie according to instruction number 1 but instruction number 2 is hard for me
sure but get confused how to create array for it
i have done with that i am having problem about work on movies challenge, i copied the array of the movie but can move to the next level
So you clearly know how to use both map and filter. Is the problem that the movie array contains objects?
-
Given this movies array of objects, how would you access the title property? For now, you don’t have to loop the array, just show how you would console.log() out the value of the first movie title.
-
How would you check the length of the title or any String?
-
How would you compare the length of the String to a number? E.g. how you would check if the length of a String is greater than, or less than, some number.
-
When using .filter() on an array of numbers you have access to each number inside the filter callback function, like you have shown using the numbers array. The same applies to an array of objects, you have access to each of the objects inside the callback. And each object has properties you can access using either square bracket or dot notation.