“String terbalik” Kode Jawaban

JavaScript membalikkan string

function reverseString(s){
    return s.split("").reverse().join("");
}
reverseString("Hello");//"olleH"
Grepper

cara mencetak input mundur dalam python

str="Python" # initial string
stringlength=len(str) # calculate length of the list
slicedString=str[stringlength::-1] # slicing 
print (slicedString) # print the reversed string
Wandering Wolf

string terbalik

def reverse_string(str):
  return str[::-1]
print(reverse_string("This string is reversed!"))
Silver Takana

String terbalik

# reverse string
st = 'Hello'
print(st[::-1])
Impossible Impala

string terbalik

Input: s = ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]
Depressed Dragonfly

String terbalik

// Reverse string

function reverseString(str) {
	let reverseStr = '';
	let i = str.length - 1;

	while (i >= 0) {
		reverseStr += str[i];
		console.log(reverseStr);
		i--;
	}
	return reverseStr;
}
reverseString('hello');

// OR

function reverseString(str) {
	for (var reversedStr = '', i = str.length - 1; i >= 0; i--) {
		reversedStr += str[i];
	}
	return reversedStr;
}

// OR

function reverseString(str( {
	result = ""
  	for (i = 0; i < str.length; i++) {
  		result = str[i] + result
  	}
  	return result 
}

// OR

function reverseString(str) {
	return str.split('').reverse().join('');
}
YosKa

Jawaban yang mirip dengan “String terbalik”

Pertanyaan yang mirip dengan “String terbalik”

Lebih banyak jawaban terkait untuk “String terbalik” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya