0
What's the problem in code?
°Code is meant to search 2 elements in array °If both element are found it will display both found °If no element found it will display not found °If 1 element is found then it will display that element found e.g.(3 Found!!) °I have certain restriction for this code 1• Only one loop 2• There should be no break in code 3• Only two variables (1 for array) and (2 for loop) Note: Everyone is telling me about one found but i want that parameter like (num1+" found ") https://code.sololearn.com/W70HIt5lquf7/?ref=app
3 Antworten
0
I would initialise show to " " and in your second if:
if ((num1===arr[i] && show[0] == num2) || (num2===arr[i] && show[0]==num1))
This will make sure you found 1, then it will check if the other has been found too.
0
It is still not working
0
Is this what you need it to output?
https://code.sololearn.com/WGSp47sxk7NR/?ref=app