I have two input value and find all crossing combination from value one to another

user firstvalue = 789;
user secondvalue = 210;

i want output = [72,71,70, 82,81,80,92,91,90];

sorry to take your time its a different function I tried to google so many times but did not get an answer

One approach would be:

  • convert first value to array: from 789 you should get [ '7', '8', '9' ]

for the above make research about toString(), split()

  • iterate through [ '7', '8', '9' ] array, using array method like map() or reduce()

there is a pattern which will help you to implement callback function for array method

for 7 you should get 72, 71, 70
for 8 you should get 82, 81, 80

1 Like
$('#crossingmultiplesubmit').click(function(){
				var firstcorssignuserinput = $('#firstcrossinginput').val();
				
				var secondcrossinginput = $('#secondcrossinginput').val();


				const firstarrayOfDigit = Array.from(String(firstcorssignuserinput), Number).map(String);
				const secondarrayOfDigit = Array.from(String(secondcrossinginput), Number).map(String);

				var outputmultiplecrosing = firstarrayOfDigit.flatMap(d => secondarrayOfDigit.map(v => d + v));

				console.log(outputmultiplecrosing);
				
		});

i used that code its worked for me thanku sir

Do you have any idea about that :
2. first input = 10 ;
second input = 50;

then i want array = [10,11,12,13,14…47,48,49,50];

on the other hand always low value to high value
first input = 50;
second input = 10;
then same output array like = [10,11,12,13…48,49,50];

I have not idea about that but I solve first equation now I face new array problem

i have multiple array then i want add value with same key name

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.