+ 3

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?

30th Jul 2021, 3:39 AM
Farooq Shah
Farooq Shah - avatar
13 Respostas
+ 6
All you need to use `%` operator to find the reminder. 5%2 =1; 6%2 = 0; 3%4 = 3;
30th Jul 2021, 4:14 AM
Simba
Simba - avatar
+ 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.
30th Jul 2021, 4:10 AM
Simba
Simba - avatar
+ 4
function main() { var numberGuests = parseInt(readLine(), 10) // Your code here if (numberGuests %2 ==0) {console.log("Right")} else {console.log("Wrong")} }
30th Jul 2021, 4:57 AM
Simba
Simba - avatar
+ 3
You can use `==` operator to compare two variables. "Cat" == "Cat" -> true "Cat" == "Dog" -> false
30th Jul 2021, 8:21 AM
Simba
Simba - avatar
+ 3
console.log(input1==input2)
30th Jul 2021, 5:43 PM
Simba
Simba - avatar
+ 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
30th Jul 2021, 5:41 AM
Farooq Shah
Farooq Shah - avatar
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")} }
30th Jul 2021, 3:55 AM
Farooq Shah
Farooq Shah - avatar
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")} }
30th Jul 2021, 4:02 AM
Farooq Shah
Farooq Shah - avatar
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
30th Jul 2021, 4:04 AM
Farooq Shah
Farooq Shah - avatar
0
Simba can u give one example plz
30th Jul 2021, 4:12 AM
Farooq Shah
Farooq Shah - avatar
0
unable to solve. plz solve for me so that i will compare with my code
30th Jul 2021, 4:28 AM
Farooq Shah
Farooq Shah - avatar
0
Simba pls summarize tabove exercise in easy way
30th Jul 2021, 9:20 AM
Farooq Shah
Farooq Shah - avatar
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); }
1st Aug 2021, 1:43 AM
Farah Islam