In WebGL 1, a texture can only use mipmaps when its width and height are powers of two: 1, 2, 4, 8, .... An asset checker warns about other sizes.
Write isPowerOfTwoSize(n) that returns true if n is a power of two and false otherwise. Zero and negative numbers are never powers of two.
Input: n = 256 Output: true
256 = 2^8, which is 100000000 in binary: a single 1 bit.
Input: n = 300 Output: false
300 is 100101100 in binary, with more than one 1 bit.
-2^31 <= n <= 2^31 - 1Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #667 Valid Texture Size. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.