Skip to content
Snippets Groups Projects
Commit af483338 authored by TIRONI Baptiste's avatar TIRONI Baptiste
Browse files

fini 1

parent cc23c470
Branches main
Tags fintd
No related merge requests found
function deb1() {
let j = 200;
let tab = [];
for (let i = 0; i < 10; i++) {
j -= 10;
tab.push(j);
}
return j;
}
function deb2(x, y) {ault
const tmp = y;
y = x;
x = tmp;
console.log(x, y);
}
let x = 10;
let y = 20;
deb2(x, y); // 20 10 (echange de valeur)
console.log(x, y); // 10 20 (pas d'échange de valeur car x et y n'ont pas été retournés par la fonction deb2)
function deb3(xy) {
let tmp = xy[0];
xy[0] = xy[1];
xy[1] = tmp;
console.log(xy);
}
let xy = [10, 20];
deb3(xy);
console.log(xy); // 20 10 (échange de valeur car xy est un tableau et les tableaux n'ont pas besoin d'être retournés)
let j = 10;
deb4();
console.log(j);
function deb4() {
let j = 25;
for (let i = 0; i < 10; i++) {
let j = 2 * i;
console.log(j); // 0 2 4 6 8 10 12 14 16 18
}
return j; // 25 car le premier let est local à la fonction deb4 et le second est local à la boucle for
}
/*let tab1 = [1, 2, 3];
let tab2 = tab1;
tab1[1] = 5;
console.log(tab1, tab2); // [1, 5, 3] [1, 5, 3] meme tableau
*/
let tab1 = [1, 2, 3];
let tab2 = [...tab1];
tab1[1] = 5;
console.log(tab1, tab2); // [1, 5, 3] [1, 2, 3] deux tableaux différents
deb7(-5, 3);
function deb7(x, y) {
let val = 0;
for (let i = 0; i < y; i++) {
val += x;
}
return val;
}
/*function deb7(x: number, y: number) : number {
return x * y;
}*/
//# sourceMappingURL=Untitled-1.js.map
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment