0
0
React Nativemobile~20 mins

Interpolation in React Native - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Interpolation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2: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();
A50
B0.5
C100
Dundefined
Attempts:
2 left
💡 Hint
Interpolation maps input values to output values linearly between ranges.
📝 Syntax
intermediate
2:00remaining
Correct Syntax for Interpolation
Which option correctly uses interpolate to map an animated value from 0-1 to 0-200?
AanimatedValue.interpolate({input: [0, 1], output: [0, 200]})
BanimatedValue.interpolate(inputRange = [0, 1], outputRange = [0, 200])
CanimatedValue.interpolate([0, 1], [0, 200])
DanimatedValue.interpolate({inputRange: [0, 1], outputRange: [0, 200]})
Attempts:
2 left
💡 Hint
interpolate expects an object with inputRange and outputRange keys.
lifecycle
advanced
2: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?
AThe interpolated output stays the same until the animation restarts.
BThe interpolated output updates immediately to reflect the new inputRange.
CThe app crashes with an error about inputRange change.
DThe interpolation resets to default values.
Attempts:
2 left
💡 Hint
Interpolation config is fixed when created; changing it later does not affect current output.
🔧 Debug
advanced
2: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();
ABecause inputRange values must be strings, not numbers.
BBecause outputRange values are strings with units, causing NaN on numeric getValue().
CBecause animatedValue must be an integer, not 0.5.
DBecause interpolate requires outputRange to be numbers only.
Attempts:
2 left
💡 Hint
getValue() returns a number; outputRange strings with units cause conversion failure.
🧠 Conceptual
expert
2: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();
A1.5
B150
C100
DNaN
Attempts:
2 left
💡 Hint
The 'clamp' option limits output to the nearest boundary value.