mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-17 16:52:52 +08:00
12 lines
173 B
JavaScript
12 lines
173 B
JavaScript
// Returns the value of x to the power of y
|
|
|
|
const pow = (x, y) => {
|
|
let result = 1
|
|
for (let i = 1; i <= y; i++) {
|
|
result *= x
|
|
}
|
|
return result
|
|
}
|
|
|
|
export { pow }
|