Skip to content

Js exercises bhavana#2

Open
bhavana1111 wants to merge 7 commits into
AkellaRaviTeja:mainfrom
bhavana1111:JSExercises-Bhavana
Open

Js exercises bhavana#2
bhavana1111 wants to merge 7 commits into
AkellaRaviTeja:mainfrom
bhavana1111:JSExercises-Bhavana

Conversation

@bhavana1111
Copy link
Copy Markdown

No description provided.

Comment thread src/exercises/6/exercise.js Outdated
console.log(`Length of the given input array is ${lengthOfArray}`);
}
let inputArray = [1, 2, 3, 4, 5];
Array.isArray(inputArray) && findTheLength(inputArray);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation should always go into the function. Or else you have to write the validation everytime you call it. Move it into the function.

Comment thread src/exercises/8/exercise.js Outdated

function printArray(inputArray) {}
function printArray(inputArray) {
console.log(inputArray);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the correct solution. But try doing it with loops.

Comment thread src/exercises/9/exercise.js Outdated

//using array function in the map methods
inputArray = inputArray.map((value) => value * 2);
console.log(`Given input array is ${inputArray}`);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Print before and after arrays. Also do not mutate the array. Take the output into a new array.

Do you think map function mutates the array or creates a new one?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map method will create a new array and return it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants