Cari Max

Run Settings
LanguageJavaScript
Language Version
Run Command
function short (arr) { let n = arr.length; let max = []; for(let i = 0; i < n-1; i++){ for(let j = 0; j < n -i-1; j++ ){ if(arr[j] > arr[j+1]){ let temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp } } } return arr; } let besar = short([4,2,5,9,7]); function max() { let numbers = [4,2,5,9,7] let maxNumber = numbers[0]; for (let i=1; i < numbers.length; i++){ if(numbers[i] > maxNumber){ maxNumber = numbers[i] } } return maxNumber; } console.log(max());
Editor Settings
Theme
Key bindings
Full width
Lines