Untitled
unknown
plain_text
7 months ago
674 B
3
Indexable
Never
import React, { useState } from 'react'; const IntegerReverser = () => { const [inputValue, setInputValue] = useState(''); const reverseInteger = (number) => { return parseInt(number.toString().split('').reverse().join('')); }; const handleInputChange = (event) => { setInputValue(event.target.value); }; const handleReverse = () => { const reversedValue = reverseInteger(inputValue); alert(`Reversed Value: ${reversedValue}`); }; return ( <div> <input type="number" value={inputValue} onChange={handleInputChange} /> <button onClick={handleReverse}>Reverse</button> </div> ); }; export default IntegerReverser;
Leave a Comment