This commit is contained in:
Philippe Torrel
2026-07-01 09:40:35 +02:00
parent f642829cb1
commit 2dbadb9c4f
11 changed files with 222 additions and 24 deletions

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
@@ -18,7 +18,16 @@
<script>
'use strict';
const reverseString = (str) => {};
const reverseString = (str) => {
if (str.length <= 1) {
return '';
}
// console.log('str.slice(1): ', str.slice(1));
// iwie kapier ich das mit den rückgabewarten von rekursiven funktionen noch net wirklich
return reverseString(str.slice(1)) + str[0];
// return ... <-- ("lo") + "l" <--- ("llo") + "e" <-- ("ello") + "h"
};
// Test cases
console.log(reverseString('hello')); // => "olleh"