“string javascript tambahkan baris baru” Kode Jawaban

JavaScript Tambahkan baris baru dalam string

//use \n like this:
var newString = "this is on line 1 \nand this is on line 2";
console.log(newString);
JotunnSlayer

JavaScript Teks Baris Baru

\r\n
Open Ox

JavaScript baris baru

console.log('Hello \n World');
Bored Beetle

string javascript tambahkan baris baru

// let's say you want to make a code output game in a web page
// and you want to add a C# code
// do it like this!
// or you could use a textarea element and type it normally

const csCode = `
static double avrg(double num1, double num2, double num3, double num4){<br>
    &ThickSpace;double rslt = (num1 + num2 + num3 + num4) / 4;<br>
    &ThickSpace;return rslt;<br>
}<br>
int[] numbers = {10, 15, 8, 4, 2, 81, 90, 34, 23};<br>
int num1 = numbers[3];<br>
int num2 = numbers[7] - 1;<br>
int num3 = numbers[2] * numbers[1];<br>
double num4 = Math.Pow(numbers[3], 3);<br>
Console.WriteLine(avrg(num1, num2, num3, num4));
`;

// and then display it with innerHTML;
document.getElementById('code-display').innerHTML = csCode;

// the ThickSpace; will make it look like a tab keypress
// and now it will look good and will not generate on 1 single line
// and this works for TypeScript as well
ST111

Karakter Pengembalian String JavaScript

var str = "HELLO WORLD";
var res = str.charAt(0);
Blue Wildebeest

Jawaban yang mirip dengan “string javascript tambahkan baris baru”

Pertanyaan yang mirip dengan “string javascript tambahkan baris baru”

Lebih banyak jawaban terkait untuk “string javascript tambahkan baris baru” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya