xxxxxxxxxx
a="grayorphanvillain"
t=a[0:-13:1]
print(t,'/',end=" ")
k=a[-13:-7:1]
print(k,'/',end=" ")
m=a[-7:]
print(m,end=" ")
#output:
gray / orphan / villain
xxxxxxxxxx
const str = 'The quick brown fox jumps over the lazy dog.';
console.log(str.slice(31)); // expected output: "the lazy dog."
console.log(str.slice(4, 19)); // expected output: "quick brown fox"
console.log(str.slice(-4)); // expected output: "dog."
console.log(str.slice(-9, -5)); // expected output: "lazy"
// source : https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/String/slice
xxxxxxxxxx
newStr = str.split(''); // or newStr = [...str];
newStr.splice(2,5);
newStr = newStr.join('');
xxxxxxxxxx
// You use this method to cut out a substring from an entire string.
// We will use this method to cut out the remaining part of a word (excluding the first letter):
const word = "freecodecamp"
const remainingLetters = word.substring(1)
// reecodecamp
xxxxxxxxxx
let x = ["a", "b", "c", "d", "e", "f"];
console.log(Array.prototype.slice.call("abcdefg"))
/*[ 'a', 'b', 'c', 'd', 'e', 'f', 'g' ]*/
/*slice can turn a string into an array with its letters as elements*/