How to print array elements in one line ,in Javascript | Sololearn: Learn to code for FREE!

0

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("]"); }

4/7/2021 11:49:55 AM

PRAKASH CHANDRA MOHAPATRA

9 Answers

New Answer

+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

+1

Thnx But it will not give space between the elements

+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

+1

https://code.sololearn.com/cH46vRj8o8KL/?ref=app

+1

0

How to print array elements like [98.99,15.2,20,1026]

0

[Space 4,space 5,space 6 space] I need this spaces which will be filled with space

0

Is this what you are trying to do?? PRAKASH CHANDRA MOHAPATRA https://code.sololearn.com/c1R7oJqBLp8C/?ref=app

0