+ 1

How to print array elements in one line ,in Javascript

function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here var n=prices.length; for(var i=0;i<n;i++) { prices[i]=prices[i]+increase; } console.log("["); for(var i=0;i<n;i++) { console.log(prices[i]); } console.log("]"); }

7th Apr 2021, 11:49 AM
PRAKASH CHANDRA MOHAPATRA
PRAKASH CHANDRA MOHAPATRA - avatar
9 Answers
+ 4
You don't need to loop over the array to print it You can just try console.log(prices); it will print it in one line
7th Apr 2021, 12:05 PM
Vinayak
Vinayak - avatar
+ 2
Thnx But it will not give space between the elements
7th Apr 2021, 12:19 PM
PRAKASH CHANDRA MOHAPATRA
PRAKASH CHANDRA MOHAPATRA - avatar
7th Apr 2021, 12:32 PM
PRAKASH CHANDRA MOHAPATRA
PRAKASH CHANDRA MOHAPATRA - avatar
+ 2
Thnx bro
7th Apr 2021, 1:48 PM
PRAKASH CHANDRA MOHAPATRA
PRAKASH CHANDRA MOHAPATRA - avatar
+ 1
How to print array elements like [98.99,15.2,20,1026]
7th Apr 2021, 11:52 AM
PRAKASH CHANDRA MOHAPATRA
PRAKASH CHANDRA MOHAPATRA - avatar
+ 1
https://code.sololearn.com/c0j561PipZ9E/?ref=app I think it gives enough space between array elements 😅 Can you tell how exactly you want the spaces
7th Apr 2021, 12:25 PM
Vinayak
Vinayak - avatar
+ 1
[Space 4,space 5,space 6 space] I need this spaces which will be filled with space
7th Apr 2021, 12:36 PM
PRAKASH CHANDRA MOHAPATRA
PRAKASH CHANDRA MOHAPATRA - avatar
7th Apr 2021, 1:17 PM
Vinayak
Vinayak - avatar
0
Oho
9th Apr 2021, 5:00 AM
S o u v i k T a r a f d e r
S o u v i k T a r a f d e r - avatar