Challenge - 5 Problems
Interpolation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
Output of Animated Interpolation
What will be the output value of
interpolatedValue when animatedValue is 0.5 in this React Native code snippet?React Native
import { Animated } from 'react-native'; const animatedValue = new Animated.Value(0.5); const interpolatedValue = animatedValue.interpolate({ inputRange: [0, 1], outputRange: [0, 100] }); interpolatedValue.__getValue();
Attempts:
2 left
💡 Hint
Interpolation maps input values to output values linearly between ranges.
✗ Incorrect
The interpolate function maps 0 to 0 and 1 to 100. Since animatedValue is 0.5, the output is halfway, which is 50.
📝 Syntax
intermediate2:00remaining
Correct Syntax for Interpolation
Which option correctly uses
interpolate to map an animated value from 0-1 to 0-200?Attempts:
2 left
💡 Hint
interpolate expects an object with inputRange and outputRange keys.
✗ Incorrect
Option D uses the correct object syntax with keys inputRange and outputRange.
❓ lifecycle
advanced2:00remaining
Effect of Changing Input Range Dynamically
If you change the
inputRange of an interpolation after the animation starts, what happens to the interpolated output?Attempts:
2 left
💡 Hint
Interpolation config is fixed when created; changing it later does not affect current output.
✗ Incorrect
Interpolation config is static after creation; changing inputRange later has no effect until re-created or animation restarted.
🔧 Debug
advanced2:00remaining
Why Does This Interpolation Return NaN?
Given this code, why does
interpolatedValue.__getValue() return NaN?React Native
const animatedValue = new Animated.Value(0.5); const interpolatedValue = animatedValue.interpolate({ inputRange: [0, 1], outputRange: ['0px', '100px'] }); interpolatedValue.__getValue();
Attempts:
2 left
💡 Hint
getValue() returns a number; outputRange strings with units cause conversion failure.
✗ Incorrect
Using strings with units in outputRange causes getValue() to fail returning NaN because it expects numeric values.
🧠 Conceptual
expert2:00remaining
Interpolation Behavior Outside Input Range
What is the output of this interpolation when
animatedValue is set to 1.5?React Native
const animatedValue = new Animated.Value(1.5); const interpolatedValue = animatedValue.interpolate({ inputRange: [0, 1], outputRange: [0, 100], extrapolate: 'clamp' }); interpolatedValue.__getValue();
Attempts:
2 left
💡 Hint
The 'clamp' option limits output to the nearest boundary value.
✗ Incorrect
With extrapolate set to 'clamp', values outside inputRange are clamped to nearest outputRange boundary, so 1.5 maps to 100.