challenge-algorithms-Ana-Ca.../03-max-value/index.html

30 lines
927 B
HTML
Raw Normal View History

2021-08-18 21:00:43 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
2021-08-18 21:00:43 +00:00
<title>Document</title>
</head>
2021-08-18 21:00:43 +00:00
<body>
2021-08-18 21:00:43 +00:00
<script>
/*
2021-08-18 21:00:43 +00:00
Faça um algoritmo que retorne o maior numero encontrado no array
*/
function maxValue(values) {
// implementar logica aqui
let higherNumber = Math.max(...values);
return higherNumber;
}
2021-08-18 21:00:43 +00:00
// Resultados esperados
console.log(maxValue([4, 6, 12, 5]), 12); // 12
console.log(maxValue([9, 234, 312, 999, 21, 2311]), 2311); // 2311
console.log(maxValue([533, 234, 23423, 32, 432]), 23423); // 23423
console.log(maxValue([5, 4, 3, 2, 1]), 5); // 5
console.log(maxValue([-1, -5, -10, -45]), -1); // -1
2021-08-18 21:00:43 +00:00
</script>
</body>
</html>