Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to print all students name having percentage more than 70% in JavaScript?
You can use a for loop and check whether the percentage is greater than 70 or not with if condition.
Following are the records of each student −
const studentDetails=
[
{
studentName:"John",
percentage:78
},
{
studentName:"Sam",
percentage:68
},
{
studentName:"Mike",
percentage:88
},
{
studentName:"Bob",
percentage:70
}
]
Now, use the for loop and et conditions for students with percentage more than 70 −
for(var index=0;index<studentDetails.length;index++)
{
if(studentDetails[index].percentage > 70)
{
//
}
}
Example
const studentDetails=
[
{
studentName:"John",
percentage:78
},
{
studentName:"Sam",
percentage:68
},
{
studentName:"Mike",
percentage:88
},
{
studentName:"Bob",
percentage:70
}
]
for(var index=0;index<studentDetails.length;index++){
if(studentDetails[index].percentage > 70){
console.log("Student Name which has more than 70
%="+studentDetails[index].studentName);
}
}
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo68.js. This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo68.js Student Name which has more than 70 %=John Student Name which has more than 70 %=Mike
Advertisements