- Modify the
greet
function inwasm-game-of-life/src/lib.rs
to take aname: &str
parameter that customizes the alerted message, and pass your name to thegreet
function from insidewasm-game-of-life/wasm-app/index.js
. Rebuild the.wasm
binary withwasm-pack build
, then refresh in your web browser and you should see a customized greeting!
Answer:
#[wasm_bindgen]
pub fn greet(name: &str) {
alert(&format!("Hello, {}!", name));
}
wasm.greet("Your name");