 # 10 Javascript questions to practice before your interview | 2021

Hey all, Welcome to Geeksforjobs

## Output : Percentage:number

```// Declaring function
function calculatePercentage(){
//declaring variable named total and using '+' operator to add marks
var total = 50+40+60+90+10;
// Declaring variable percent and storing percent calculated by formulae given using operators '*' and "https://geeksforjobs.com/"
var percent = (total*1)/5;
//returning percent.
return percent;
}

// Required: exports module for other modules to use
module.exports = calculatePercentage;
```

## 2] Program to calculate the area of a right triangle. The area of a right triangle is (½ x base x height).Output:Your output code should return the area in the output variable.

```getArea = function(base, height){
var area = 1/2*(base*height);
return area;
}
```

## Output: Your output code should return the temperature in output variable.

```conversion = function(c){
f = ((9/5)*c) + 32;
return f;
}
```

## 4] program to convert given value in Indian rupees to US dollars. Exchange Rate is as follows: 1 USD = 75 INR . Take input variables (INR) as the parameter of your function.Output: Your output code should return the value of currency in output variable.

```conversion=function(inr){
usd= (inr)/75;
return usd;
}```

## 5] Program which returns 1 if a given year is leap year and 0 if the given year is not leap year.

```leapyr=function(year){
if(year%4==0){
if(year%100==0){
if(year %400==0){
return 1;
}
else{
return 0;
}
}
return 1;
}
else{
return 0;
}
}```

## If the number is less than 13, the program calculate the difference between 13 and input number and returns the value as result. Take input variables (number1) as parameter of your function.Output : Your output code should return the difference between 13 and input number in output variable.

```findopr=function(number1){
if(number1>13){
f=(number1-13)*2;
return f;
}
else{
f=(number1-13);
return f;
}
}

```

## Output : Your output code should return the sum in output variable.

```answer=function(number1,number2){
if(number1==number2){
sum=number1+number2;

return (3*sum);

}
else{
return number1+number2;
}
}
```

## 8] Program to check two given numbers. The program should return true if one of the number is 50 or if their sum is 50 and returns false otherwise. Take input variables (number1, number2) as the parameter of your function.Output : Your output code should return the boolean value in output variable.

```boolans=function(number1,number2){
sum=number1+number2;
if(number1==50 || number2==50 || sum==50){
return true;
}
else{
return false;
}
}
```

## 9] Program should return true if a given number lies in the range from 80 to 120 or from 380 to 420 and false otherwise. Take input variables (number1) as a parameter of your function.Output : Your output code should return boolean value in output variable.

```find=function(number1){
if(number1>80 && number1<120){
return true;
}
else if(number1>380 && number1<420){
return true;
}
else{
return false;
}
}
```

## 10] Program to check two given integers and returns true if one is positive and other is negative, and false otherwise. Take input variables (number1, number2) as the parameter of your function.Output : Your output code should return the boolean value in output variable.

```findans=function(number1,number2){
if(number1>0 || number2>0){
return true;
}

else{
return false;
}
}
```