text: Construct two N | Satisfying the given conditions ; Declare the two arrays A and B ; Iterate from range [ 1 , 2 * n ] ; Assign consecutive numbers to same indices of the two arrays ; Print the first array ; Print the second array , B ; Driver Code ; Function Call
code: function printArrays ( n ) { let A = [ ] ; let B = [ ] ; for ( let i = 1 ; i <= 2 * n ; i ++ ) { if ( i % 2 == 0 ) A . push ( i ) ; else B . push ( i ) ; } document . write ( " " ) ; for ( let i = 0 ; i < n ; i ++ ) { document . write ( A [ i ] ) ; if ( i != n - 1 ) document . write ( " " ) ; } document . write ( " " + " " ) ; document . write ( " " ) ; for ( let i = 0 ; i < n ; i ++ ) { document . write ( B [ i ] ) ; if ( i != n - 1 ) document . write ( " " ) ; } document . write ( " " ) ; } let N = 5 ; printArrays ( N ) ;