AWS Certified Developer Associate DVA-C02 Practice Question

A developer is working on an application that needs to store and retrieve player data for an online game. The game's backend is using AWS services for its infrastructure. The developer has chosen Amazon DynamoDB for storing player data. Each player has a 'PlayerID' as the unique identifier and various attributes like 'Score', 'Level', and 'Items'. The developer needs to write code to update a player's 'Score' after completing a game session. Which code snippet, assuming the AWS SDK for JavaScript is being used, correctly and efficiently updates the 'Score' attribute for a given 'PlayerID' without affecting other attributes?

  • dynamodb.put({TableName: 'Players', Item: {'PlayerID': playerId, 'Score': newScore}})

  • dynamodb.getItem({TableName: 'Players', Key: {'PlayerID': playerId}}, function(err, data) { if (!err) { data.Item.Score = newScore; dynamodb.put({TableName: 'Players', Item: data.Item}); }})

  • dynamodb.update({TableName: 'Players', Key: {'PlayerID': playerId}, UpdateExpression: 'REMOVE Score SET Score = :newScore', ExpressionAttributeValues: {':newScore': newScore}})

  • dynamodb.update({TableName: 'Players', Key: {'PlayerID': playerId}, UpdateExpression: 'SET Score = :newScore', ExpressionAttributeValues: {':newScore': newScore}})

  • dynamodb.scan({TableName: 'Players', FilterExpression: 'PlayerID = :playerId', ExpressionAttributeValues: { ':playerId': playerId }, ProjectionExpression: 'Score'}, function(err, data) { var items = data.Items; for (var i=0; i < items.length; i++) { if (items[i].PlayerID == playerId) { items[i].Score = newScore; } }})

  • dynamodb.update({TableName: 'Players', Key: {'PlayerID': playerId}, UpdateExpression: 'ADD Score :increment', ExpressionAttributeValues: {':increment': scoreIncrement}})

AWS Certified Developer Associate DVA-C02
Development with AWS Services
Your Score:
Settings & Objectives
Random Mixed
Questions are selected randomly from all chosen topics, with a preference for those you haven’t seen before. You may see several questions from the same objective or domain in a row.
Rotate by Objective
Questions cycle through each objective or domain in turn, helping you avoid long streaks of questions from the same area. You may see some repeat questions, but the distribution will be more balanced across topics.

Check or uncheck an objective to set which questions you will receive.

Bash, the Crucial Exams Chat Bot
AI Bot