Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8dc1375

Browse files
solved some tasks related to the forEach()method to remember this methods
1 parent ffeff81 commit 8dc1375

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

‎Array methods/script.js

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,3 +425,112 @@
425425
// const res = arr.flat(Infinity);
426426
// console.log(res);
427427

428+
429+
// MY SOLUTIONS TO SOME QUESTIONS BASED ON ARRAY METHODS JS //
430+
431+
// const num = [1,2,3,4,5]
432+
// let square = []
433+
// num.forEach(function(value){
434+
// const squares = value * value;
435+
// square.push(squares)
436+
// })
437+
// console.log(square);
438+
439+
440+
// const names = ['ali','hali','mali']
441+
// names.forEach(function(value){
442+
// console.log(value +" "+ 'Assalomu Alaykum')
443+
// })
444+
445+
// const products = [
446+
// {
447+
// name:'Laptop',
448+
// price:1200
449+
// },
450+
// {
451+
// name:'Phone',
452+
// price:3000
453+
// },
454+
// {
455+
// name:'Earphone',
456+
// price:200
457+
// }
458+
// ]
459+
// let totalPrice = 0;
460+
// products.forEach(function(value){
461+
// totalPrice+=value.price
462+
// })
463+
// console.log(totalPrice);
464+
465+
// const names = ['ali','hali','mali','kali'];
466+
// names.forEach(function(string){
467+
// console.log(string.charAt(0).toUpperCase() + string.slice(1))
468+
// })
469+
470+
// const num = [1,3,4,7,0,54,43,67,23,32]
471+
// let MaxNumber = num[0]
472+
// num.forEach(function(number){
473+
// if(number > MaxNumber){
474+
// MaxNumber = number
475+
// }
476+
// })
477+
// console.log('Maximum number is: ',MaxNumber);
478+
479+
480+
// const students = [
481+
// {
482+
// name:'John',
483+
// score:29
484+
// },
485+
// {
486+
// name:'John',
487+
// score:45
488+
// },
489+
// {
490+
// name:'John',
491+
// score:76
492+
// },
493+
// {
494+
// name:'John',
495+
// score:80
496+
// },
497+
// {
498+
// name:'John',
499+
// score:56
500+
// },
501+
// {
502+
// name:'John',
503+
// score:43
504+
// },
505+
// ]
506+
507+
// let totalScore = 0;
508+
// let totalStudents = 0;
509+
510+
// students.forEach(function(student){
511+
// totalScore += student.score;
512+
// totalStudents++;
513+
// })
514+
515+
// const averageScore = Math.floor(totalScore / totalStudents);
516+
// console.log('Average Score is :',averageScore);
517+
518+
519+
// const names = ['alids','hal','mali','kalids'];
520+
521+
// names.forEach(function(string,index){
522+
// if(string.length < 4){
523+
// names.splice(index,1)
524+
// }
525+
// })
526+
// console.log(names);
527+
528+
529+
// const numbers = [2,43,5,6,8,23,56,10,56,76,4,5,75];
530+
// let num = 0;
531+
// numbers.forEach(function(number){
532+
// if(number > 10){
533+
// num++;
534+
// }
535+
// })
536+
// console.log(num);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /