js test exercises | Sololearn: Learn to code for FREE!

+2

js test exercises

hello everyone when i try to solve test exercises foor js the problem statement tell me to enter sample input and when i took sample input result for "test case 1" is true but 2 other test was cases result is incorrect. And when i try to put input from result of exercise of test case 2 which tells input fre "test case 2" the other test case 1 and test case result 3 was incorrect. Can anyone tells me how to solve. Also if i donot enter input for test case 2 and 3 so why it gives result for those cases?

7/30/2021 3:39:03 AM

Farooq Shah

13 Answers

New Answer

+6

All you need to use `%` operator to find the reminder. 5%2 =1; 6%2 = 0; 3%4 = 3;

+5

It's similar to find odd and even numbers. All you need to check that if your input is divisible by 2 (reminder is zero) or not. if yes, print 'Right' else "Wrong". You can do it with one main function. It's not necessary to declare many functions.

+4

function main() { var numberGuests = parseInt(readLine(), 10) // Your code here if (numberGuests %2 ==0) {console.log("Right")} else {console.log("Wrong")} }

+3

You can use `==` operator to compare two variables. "Cat" == "Cat" -> true "Cat" == "Dog" -> false

+3

console.log(input1==input2)

+1

Simba plz explain me to solve this Reset account passwords should not be the same as the old password. Task Write a program that takes old and new passwords as inputs and outputs to the console the boolean value (true or false) that shows whether or not they match. Sample Input hl8792m hl8792m Sample Output true

0

Simba here it is my code function main() { var numberGuests = parseInt(readLine(), 10) // Your code here if (numberGuests ==14) {console.log("Right")} else {console.log("Wrong")} }

0

Simba here is code with all 3 cases. case 1 incorrect and case 2 and 3 are correct function main() { var numberGuests = parseInt(readLine(), 10) // Your code here if (numberGuests == 14) {console.log("Right")} else {console.log ("Wrong")} } function main() { var numberGuests = parseInt(readLine(), 10) // Your code here if (numberGuests == 23) {console.log("Right")} else {console.log ("Wrong")} } function main() { var numberGuests = parseInt(readLine(), 10) // Your code here if (numberGuests == 24) {console.log("Right")} else {console.log ("Wrong")} }

0

Simba task is below Entrance to the club is only permitted in pairs. Take the number of customers in the club as input, and, if all of them have a pair, output to the console "Right", otherwise output "Wrong". Sample Input 14 Sample Output Right

0

Simba can u give one example plz

0

unable to solve. plz solve for me so that i will compare with my code

0

Simba pls summarize tabove exercise in easy way

0

To solve the change password practice please use this code: function main() { var oldPass = readLine(); var newPass = readLine(); // Your code goes here var x = "oldPass"; var y = "newPass"; // newPass == oldPass true console.log(oldPass == newPass); }